// // Interactive illustration of gaussian filtering // Works on an image sequence or picture from camera // // John Robinson, 2004. #include "picture.h" int main(int argc, char *argv[]) { colour_picture in(argc, argv, 240, 320); // Above line sets up in as the sequence-processing picture. Calls // to next() on this picture will either grab another picture from // the camera (if no arguments), or load the next input picture // from the list of arguments. picture_of_int inmono(in); picture_of_int out(in.nrows(),in.ncols()); in.show("Input"); out.show("Output"); picture_of_int impulse(48,48); picture_of_int kern(48,48); colour_picture kernal_graph(80,100); colour_picture kernal_display(100,300); impulse = 0; impulse[24][24] = 10000; kernal_display.show("Kernel"); parampic stddevcontrol(0,0.2,10,2,0,0,0,"standard deviation"); double stddev = 2.0; while(!in.closerequested() && !out.closerequested()) { in.next(); // Get the next picture inmono = in; stddevcontrol.X(stddev); // See if the user has changed param out.gaussfilter(inmono,stddev); kern.gaussfilter(impulse,stddev); in.reshow(); out.reshow(); // Make a cross section graph of the kernel kernal_graph = 0; kernal_graph.green.draw_graph(kern[24],48,kern.max(),-1,-1); // Note use of kern.max() for the shade colour, to ensure // that the graph is visible no matter how high the kernal // And put the image version and the graph version of the // kernel into a displayed picture kernal_display.paste_centred_on(kern,50,50); kernal_display.paste_centred_on(kernal_graph,200,50); kernal_display.reshow(); } return 0; }