//======================================================================================= // // cliptest.c - for CLIP library testing // // compilation: gcc cliptest.c clip.c // // run: cliptest imagefile.pgm // // result image: saved in file "result.pgm" // //======================================================================================= #include #include "clip.h" //======================================================================================= int main(int nArgs, char** ppArgs) { int nW; // image width int nH; // image height byte* pInp; // input image (from file) byte* pOut; // output image byte* pOut2; // output image char filename[256]; double fR; strcpy(filename, ppArgs[1]); // read pgm image file if( ReadPGM(filename, &pInp, &nW, &nH) ) { printf("Can't open file\n"); return 1; }; pOut = (byte* ) malloc(nW*nH); pOut2 = (byte* ) malloc(nW*nH); // processing: //FrameBinaryAndConstB(pInp, pOut, nW, nH, 0xF8); FrameDownsampleB(pInp, pOut, nW, nH); // FrameMagnifyB(pOut, pOut2, nW/2, nH/2); // fR = FrameSnrCalcB(pInp, pOut2, nW, nH); printf("snr=%8.2f\n",fR); // write result to pgm file WritePGM("res.pgm", pOut2, nW, nH); //------------- free(pInp); free(pOut); return 0; }