// Simple radial correction demonstration. // Uses just one parameter // // John Robinson 2004. #include "picture.h" int main(int argc, char *argv[]) { colour_picture in(argc, argv, 480, 640, 80); // Set up sequence processing. The paramters 480, 640 are the // size of the camera image if there are no arguments. // Parameter 80 is for large border because we'll be doing geometric // transforms that go into the border area. double corr; parampic corrpic(-0.1,0.1,0,"Radial parameter"); in.show("Input"); colour_picture out(in); out.show("Output"); const int origy(out.nrows()/2); const int origx(out.ncols()/2); double oldx, oldy; while(!in.closerequested() && !out.closerequested()) { in.next(); in.dc_pad(); // Extend the values on the pictures borders out. in.reshow(); corrpic.X(corr); for (int newy = 0; newy < out.nrows(); newy++) for (int newx = 0; newx < out.ncols(); newx++) { int y = newy - origy; int x = newx - origx; double rsquared = (double)y*y + x*x; double offset = corr*rsquared/(double)(origx*origy); oldy = y - offset*y + origy; oldx = x - offset*x + origx; out.map(newx,newy,in,oldx,oldy,0); } out.reshow(); } return 1; }