//********************************************************************************** // //...Modulation Transfer Function (edge trace) // //...C.T. Yeung // //...4-29-94 // //...This program is created to determine the resolution of our current Kodak 4000. // However, this program will be used to determine the resolution for all of our // imaging equipment. // //...Input requirement for this program is a 1 or 2-D image of an edge. // Also known as step function or half of a rect // //...Output of this program is an array to be opened in xcel for plotting. // //...version 1 // //*********************************************************************************** #include #include #include const int MAXPIX=128; const double pi=3.1416; //variables in readimage() char imagename[20]; int imagewidth=0; int imageheight=0; //variables in kernel() int kernelwidth=0; int kernel[9]; double coef=0.0; //variables in derivative() unsigned char image[MAXPIX]; //input image double der[MAXPIX]; //output image char dername[20]= "derivative"; //variables in fourier() double real[MAXPIX]; double imag[MAXPIX]; double mtf[MAXPIX]; char mtfname[20]= "mtf"; char realname[20]= "real"; readimage() { cout << "**********************INPUT IMAGE**********************\n\n"; cout << "\nenter the name of the file you want to mess with\n\n"; cin >> imagename; cout << "\n\n What is the width of " << imagename << "\n\n"; cin >> imagewidth; cout << "hello!! I am about to read in the image...\n\n"; // test ifstream in (imagename); in.read((unsigned char*) &image, imagewidth); in.close(); for (int a=0; a<20; a++) // test parameter { cout << "\n (in readimage) image " << a << " is " << (int)image[a]; } return 0; } kern() { cout << "\n\n***************************KERNEL****************************\n\n"; cout << "\n\n What is the width of the kernel? (1 to 9) \n\n"; cin >> kernelwidth; cout << "kernelwidth is "<< kernelwidth << "\n\n"; for (int y=0; y> kernel[y]; coef += kernel[y]; } cout << "\n the coefficient is \t " << coef << "\n\n"; cout << "\n\n the kernel you have input is as follows: \n\n"; for (int x=0; x> outfile; ofstream hist_out(outfile); for (int a=0; a> outfile; ofstream out(outfile); out.write((unsigned char*)&array, imagewidth); out.close(); return 0; } main() { readimage(); kern(); derivative(); fourier(); magnitude(); histout(mtf, mtfname); /*readout(der, dername); readout(mtf, mtfname); */ return 0; }