F32vec getForce(F32vec pos) { F32 ia[3] = {0., 0., 0.}; Particle p; p.xpos = pos[0]; p.ypos = pos[1]; p.zpos = pos[2]; pm_->forceInterpolation(&p, ia); F32vec apm(ia[0], ia[1], ia[2]); return apm; }
int main(int c, char *v[]) { // process input arguments if (c != 7) { fprintf(stderr, "usage:\n\t" "%s a.png b.png dmin dmax dout.tiff cout.tiff\n", *v); // 0 1 2 3 4 5 6 return 1; } char *filename_a = v[1]; char *filename_b = v[2]; char *str_dmin = v[3]; char *str_dmax = v[4]; char *filename_dout = v[5]; char *filename_cout = v[6]; // read input images int aw, ah, apd, bw, bh, bpd; float *a = iio_read_image_float_vec(filename_a, &aw, &ah, &apd); float *b = iio_read_image_float_vec(filename_b, &bw, &bh, &bpd); if (apd != bpd) exit(fprintf(stderr,"ERROR: image color depth mismatch\n")); // create dmin and dmax images float *dmin = malloc(aw * ah * sizeof*dmin); float *dmax = malloc(aw * ah * sizeof*dmax); for (int i = 0; i < aw * ah; i++) { dmin[i] = atof(str_dmin); dmax[i] = atof(str_dmax); } // create output images float *dout = malloc(aw * ah * sizeof*dout); // disparities float *cout = malloc(aw * ah * sizeof*cout); // costs int *pout = malloc(aw * ah * 2 * sizeof*pout); // chosen planets // run the algorithm apm(dout, cout, pout, a, aw, ah, b, bw, bh, apd, dmin, dmax); // save the output images iio_write_image_float(filename_dout, dout, aw, ah); iio_write_image_float(filename_cout, cout, aw, ah); iio_write_image_int_vec("pout.tiff", pout, aw, ah, 2); // cleanup and exit return 0; }