int main(int argc, char *argv[]) { if (argc != 5) { fprintf(stderr, "usage:\n\t" "%s boundary.png data.png mask.png out.png\n", *argv); // 0 1 2 3 4 return 1; } char *filename_inpu = argv[1]; char *filename_data = argv[2]; char *filename_mask = argv[3]; char *filename_out = argv[4]; int w[3], h[3]; float *inpu = iio_read_image_float(filename_inpu, w, h); float *data = iio_read_image_float(filename_data, w+1, h+1); float *mask = iio_read_image_float(filename_mask, w+2, h+2); if (w[0] != w[1] || h[0] != h[1] || w[0] != w[2] || h[0] != h[2]) return fprintf(stderr, "input image files sizes mismatch"); float *out = xmalloc(*w**h*sizeof*out); for (int i = 0; i < *w * *h; i++) if (mask[i] > 0) inpu[i] = NAN; int nscales = NSCALES(); poisson_recursive(out, inpu, data, *w, *h, nscales); iio_write_image_float(filename_out, out, *w, *h); return 0; }
int main_compute(int c, char *v[]) { // input arguments bool do_only_warp = pick_option(&c, &v, "w", NULL); if (do_only_warp) return main_warp(c, v); bool do_center = pick_option(&c, &v, "c", NULL); if (c != 7) { fprintf(stderr, "usage:\n\t" "%s a.png b.png Pa.txt Pb.txt in.tiff out.tiff\n", *v); // 0 1 2 3 4 5 6 return 1; } char *filename_a = v[1]; char *filename_b = v[2]; char *matrix_pa = v[3]; char *matrix_pb = v[4]; char *filename_in = v[5]; char *filename_out = v[6]; // read input images and matrices int wa, wb, wi, ha, hb, hi; float *a = iio_read_image_float(filename_a, &wa, &ha); float *b = iio_read_image_float(filename_b, &wb, &hb); float *h0 = iio_read_image_float(filename_in, &wi, &hi); double PA[8], PB[8]; read_n_doubles_from_string(PA, matrix_pa, 8); read_n_doubles_from_string(PB, matrix_pb, 8); // perform centering, if necessary if (do_center) { center_projection(PA, wa/2, ha/2); center_projection(PB, wb/2, hb/2); } // allocate space for output image float *out = xmalloc(wi * hi * sizeof*out); // run the algorithm float alpha2 = ALPHA()*ALPHA(); int niter = NITER(); int nwarps = NWARPS(); int nscales = NSCALES(); mnehs_affine_ms(out, h0, wi, hi, a, wa, ha, b, wb, hb, PA, PB, alpha2, niter, nscales); //for (int i = 0; i < nwarps; i++) //{ // mnehs_affine(out, h0, wi,hi, a,wa,ha, b,wb,hb, PA, PB, alpha2, niter); // memcpy(h0, out, wi * hi * sizeof*h0); //} // save the output image iio_save_image_float(filename_out, out, wi, hi); // cleanup and exit free(out); free(h0); free(a); free(b); return 0; }
void lapbe_colorizer(float *outhue, float *outint, float *metric, float *color, int w, int h, int pd) { float tstep = TSTEP(); int niter = NITER(); int nscales = NSCALES(); float *tmpi = xmalloc(w*h*sizeof*tmpi); float *tmpo = xmalloc(w*h*sizeof*tmpo); for (int l = 0; l < pd; l++) { for (int i = 0; i < w*h; i++) tmpi[i] = grayP(color + i*pd, pd) ? NAN : color[i*pd+l]; lapbediag_rec(tmpo, metric, tmpi, w, h, tstep, niter, nscales); for (int i = 0; i < w*h; i++) outhue[i*pd+l] = tmpo[i]; } free(tmpo); free(tmpi); for (int i = 0; i < w*h; i++) normalize_intensity(outint+i*pd, outhue+i*pd, color+i*pd, pd); }