//=================================================================================== // // clip.c // // CLassic Image Processing (CLIP) Library // // version 0.1 (Jan 2004) // // developer: Henry Guennadi Levkin // // all functions are clear for reading, but not speed optimized // // frame - grey scale image or color component // image - 3 frames with color information // // B at the end of function name means that pixel has byte size // S at the end of function name means that pixel has short (2 bytes) size // // v - intensity of pixel // //=================================================================================== #include #include #include #include #include "clip.h" //----------------------------------------------------------------------------------- // allocate memory and fill by zeros void FrameConstructB(byte** ppFrm, int nW, int nH) { int nSize = nW * nH; int i; *ppFrm = (byte*) malloc(nSize); for(i=0; i0) b = 255; else b = (byte) pixel; pDst[i] = b; } } //----------------------------------------------------------------------------------- // transform from (min,max) to (0,255) void FrameS2BSqueeze(short* pSrc, byte* pDst, int nW, int nH) { int nSize = nW * nH; int i; int nMin = pSrc[0]; int nMax = pSrc[0]; int nDelta; for(i=1; i nMax) nMax = pSrc[i]; } if(nMin==nMax) { if(nMin<0) nMin = 0; else if(nMin>255) nMin = 255; memset(pDst, (byte)nMin, nSize); return; } nDelta = nMax - nMin; for(i=0; i=0) && (k nMax) nMax = pFrm[i]; } *pnMin = nMin; *pnMax = nMax; } //----------------------------------------------------------------------------------- // *pnMin - minimal intensity of pixels // *pnMax - maximal intensity of pixels void FrameMinMaxS(short* pFrm, int nW, int nH, int* pnMin, int* pnMax) { int nSize = nW * nH; int i; int nMin = pFrm[0]; int nMax = pFrm[0]; for(i=0; i nMax) nMax = pFrm[i]; } *pnMin = nMin; *pnMax = nMax; } //----------------------------------------------------------------------------------- void FrameMeanStdDevB(byte* pFrm, int nW, int nH, double* pfMean, double* pfStdDev) { int nSize = nW * nH; int i; double fMean = 0.; double fStdDev = 0.; for(i=0; i nW ) return; if( (rect.yT+rect.nH) > nH ) return; for(i=0; i nW ) return; if( (rect.yT+rect.nH) > nH ) return; for(i=0; i nW ) return; if( (rect.yT + rect.nH) > nH ) return; for(i=0; inW ) return; if( (rect.yT+rect.nH)>nH ) return; for(i=0; i> nConst void FrameBinaryShiftRightConstB(byte* pSrc, byte* pDst, int nW, int nH, int nConst) { int i; int nSize = nW * nH; if (nConst>7) return; for(i=0; i> nConst; } //----------------------------------------------------------------------------------- // v= v << nConst void FrameBinaryShiftLeftConstB(byte* pSrc, byte* pDst, int nW, int nH, int nConst) { int i; int nSize = nW * nH; if (nConst>7) return; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = - 2*(int) pSrc[i2m*nW + j2m] - (int) pSrc[i2m*nW + j1m] + (int) pSrc[i2m*nW + j1p] + 2*(int) pSrc[i2m*nW + j2p]; acc = acc - 2*(int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] + (int) pSrc[i1m*nW + j1p] + 2*(int) pSrc[i1m*nW + j2p]; acc = acc - 2*(int) pSrc[i*nW + j2m] - (int) pSrc[i*nW + j1m] + (int) pSrc[i*nW + j1p] + 2*(int) pSrc[i*nW + j2p]; acc = acc - 2*(int) pSrc[i1p*nW + j2m] - (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j1p] + 2*(int) pSrc[i1p*nW + j2p]; acc = acc - 2*(int) pSrc[i2p*nW + j2m] - (int) pSrc[i2p*nW + j1m] + (int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (short) acc; } } } //----------------------------------------------------------------------------------- // -2 -1 0 1 2 // -2 -1 0 1 2 // -2 -1 0 1 2 // -2 -1 0 1 2 // -2 -1 0 1 2 void FrameGradX5S(short* pSrc, short* pDst, int nW, int nH) { int i,j; int i1m, i1p; int i2m, i2p; int j1m, j1p; int j2m, j2p; int acc; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = - 2*(int) pSrc[i2m*nW + j2m] - (int) pSrc[i2m*nW + j1m] + (int) pSrc[i2m*nW + j1p] + 2*(int) pSrc[i2m*nW + j2p]; acc = acc - 2*(int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] + (int) pSrc[i1m*nW + j1p] + 2*(int) pSrc[i1m*nW + j2p]; acc = acc - 2*(int) pSrc[i*nW + j2m] - (int) pSrc[i*nW + j1m] + (int) pSrc[i*nW + j1p] + 2*(int) pSrc[i*nW + j2p]; acc = acc - 2*(int) pSrc[i1p*nW + j2m] - (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j1p] + 2*(int) pSrc[i1p*nW + j2p]; acc = acc - 2*(int) pSrc[i2p*nW + j2m] - (int) pSrc[i2p*nW + j1m] + (int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (short) acc; } } } //----------------------------------------------------------------------------------- // -2 -2 -2 -2 -2 // -1 -1 -1 -1 -1 // 0 0 0 0 0 // 1 1 1 1 1 // 2 2 2 2 2 void FrameGradY5B(byte* pSrc, short* pDst, int nW, int nH) { int i,j; int i1m, i1p; int i2m, i2p; int j1m, j1p; int j2m, j2p; int acc; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = - 2*(int) pSrc[i2m*nW + j2m] - 2*(int) pSrc[i2m*nW + j1m] - 2*(int) pSrc[i2m*nW + j] - 2*(int) pSrc[i2m*nW + j1p] - 2*(int) pSrc[i2m*nW + j2p]; acc = acc - (int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] - (int) pSrc[i1m*nW + j] - (int) pSrc[i1m*nW + j1p] - (int) pSrc[i1m*nW + j2p]; acc = acc + (int) pSrc[i1p*nW + j2m] + (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j] + (int) pSrc[i1p*nW + j1p] + (int) pSrc[i1p*nW + j2p]; acc = acc + 2*(int) pSrc[i2p*nW + j2m] + 2*(int) pSrc[i2p*nW + j1m] + 2*(int) pSrc[i2p*nW + j] + 2*(int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (short) acc; } } } //----------------------------------------------------------------------------------- // -2 -2 -2 -2 -2 // -1 -1 -1 -1 -1 // 0 0 0 0 0 // 1 1 1 1 1 // 2 2 2 2 2 void FrameGradY5S(short* pSrc, short* pDst, int nW, int nH) { int i,j; int i1m, i1p; int i2m, i2p; int j1m, j1p; int j2m, j2p; int acc; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = - 2*(int) pSrc[i2m*nW + j2m] - 2*(int) pSrc[i2m*nW + j1m] - 2*(int) pSrc[i2m*nW + j] - 2*(int) pSrc[i2m*nW + j1p] - 2*(int) pSrc[i2m*nW + j2p]; acc = acc - (int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] - (int) pSrc[i1m*nW + j] - (int) pSrc[i1m*nW + j1p] - (int) pSrc[i1m*nW + j2p]; acc = acc + (int) pSrc[i1p*nW + j2m] + (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j] + (int) pSrc[i1p*nW + j1p] + (int) pSrc[i1p*nW + j2p]; acc = acc + 2*(int) pSrc[i2p*nW + j2m] + 2*(int) pSrc[i2p*nW + j1m] + 2*(int) pSrc[i2p*nW + j] + 2*(int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (short) acc; } } } //----------------------------------------------------------------------------------- // abs = |Gx| + |Gy| void FrameGradAbs5B(byte* pSrc, short* pDst, int nW, int nH) { int i,j; int i1m, i1p; int i2m, i2p; int j1m, j1p; int j2m, j2p; int nGx, nGy; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; nGx = - 2*(int) pSrc[i2m*nW + j2m] - (int) pSrc[i2m*nW + j1m] + (int) pSrc[i2m*nW + j1p] + 2*(int) pSrc[i2m*nW + j2p]; nGx = nGx - 2*(int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] + (int) pSrc[i1m*nW + j1p] + 2*(int) pSrc[i1m*nW + j2p]; nGx = nGx - 2*(int) pSrc[i*nW + j2m] - (int) pSrc[i*nW + j1m] + (int) pSrc[i*nW + j1p] + 2*(int) pSrc[i*nW + j2p]; nGx = nGx - 2*(int) pSrc[i1p*nW + j2m] - (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j1p] + 2*(int) pSrc[i1p*nW + j2p]; nGx = nGx - 2*(int) pSrc[i2p*nW + j2m] - (int) pSrc[i2p*nW + j1m] + (int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; nGy = - 2*(int) pSrc[i2m*nW + j2m] - 2*(int) pSrc[i2m*nW + j1m] - 2*(int) pSrc[i2m*nW + j] - 2*(int) pSrc[i2m*nW + j1p] - 2*(int) pSrc[i2m*nW + j2p]; nGy = nGy - (int) pSrc[i1m*nW + j2m] - (int) pSrc[i1m*nW + j1m] - (int) pSrc[i1m*nW + j] - (int) pSrc[i1m*nW + j1p] - (int) pSrc[i1m*nW + j2p]; nGy = nGy + (int) pSrc[i1p*nW + j2m] + (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j] + (int) pSrc[i1p*nW + j1p] + (int) pSrc[i1p*nW + j2p]; nGy = nGy + 2*(int) pSrc[i2p*nW + j2m] + 2*(int) pSrc[i2p*nW + j1m] + 2*(int) pSrc[i2p*nW + j] + 2*(int) pSrc[i2p*nW + j1p] + 2*(int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (short) (abs(nGx) + abs(nGy)); } } } //----------------------------------------------------------------------------------- // 0 -1 0 // -1 4 -1 // 0 -1 0 void FrameLaplace3CrossB(byte* pSrc, short* pDst, int nW, int nH) { int i,j; int i1m, i1p; int j1m, j1p; int acc; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = + (int) pSrc[i2m*nW + j2m] + (int) pSrc[i2m*nW + j1m] + (int) pSrc[i2m*nW + j] + (int) pSrc[i2m*nW + j1p] + (int) pSrc[i2m*nW + j2p]; acc = acc + (int) pSrc[i1m*nW + j2m] + (int) pSrc[i1m*nW + j1m] + (int) pSrc[i1m*nW + j] + (int) pSrc[i1m*nW + j1p] + (int) pSrc[i1m*nW + j2p]; acc = acc + (int) pSrc[i*nW + j2m] + (int) pSrc[i*nW + j1m] + (int) pSrc[i*nW + j] + (int) pSrc[i*nW + j1p] + (int) pSrc[i*nW + j2p]; acc = acc + (int) pSrc[i1p*nW + j2m] + (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j] + (int) pSrc[i1p*nW + j1p] + (int) pSrc[i1p*nW + j2p]; acc = acc + (int) pSrc[i2p*nW + j2m] + (int) pSrc[i2p*nW + j1m] + (int) pSrc[i2p*nW + j] + (int) pSrc[i2p*nW + j1p] + (int) pSrc[i2p*nW + j2p]; pDst[i*nW + j] = (byte) ( (acc+12) / 25); } } } //----------------------------------------------------------------------------------- // 1 1 1 1 1 // 1 1 1 1 1 // 1 1 1 1 1 // 1 1 1 1 1 // 1 1 1 1 1 void FrameSmooth5ThresholdB(byte* pSrc, byte* pDst, int nW, int nH, int nThreshold) { int i,j; int i1m, i1p; int i2m, i2p; int j1m, j1p; int j2m, j2p; int acc; for(i=0; i= nH) i2p = nH-1; for(j=0; j= nW) j1p = nW - 1; acc = + (int) pSrc[i2m*nW + j2m] + (int) pSrc[i2m*nW + j1m] + (int) pSrc[i2m*nW + j] + (int) pSrc[i2m*nW + j1p] + (int) pSrc[i2m*nW + j2p]; acc = acc + (int) pSrc[i1m*nW + j2m] + (int) pSrc[i1m*nW + j1m] + (int) pSrc[i1m*nW + j] + (int) pSrc[i1m*nW + j1p] + (int) pSrc[i1m*nW + j2p]; acc = acc + (int) pSrc[i*nW + j2m] + (int) pSrc[i*nW + j1m] + (int) pSrc[i*nW + j] + (int) pSrc[i*nW + j1p] + (int) pSrc[i*nW + j2p]; acc = acc + (int) pSrc[i1p*nW + j2m] + (int) pSrc[i1p*nW + j1m] + (int) pSrc[i1p*nW + j] + (int) pSrc[i1p*nW + j1p] + (int) pSrc[i1p*nW + j2p]; acc = acc + (int) pSrc[i2p*nW + j2m] + (int) pSrc[i2p*nW + j1m] + (int) pSrc[i2p*nW + j] + (int) pSrc[i2p*nW + j1p] + (int) pSrc[i2p*nW + j2p]; acc = (acc+12) / 25; if(abs(acc-pSrc[i*nW + j]) <= nThreshold) pDst[i*nW + j] = acc; else pDst[i*nW + j] = pSrc[i*nW + j]; } } } //----------------------------------------------------------------------------------- // 2 7 12 7 2 // 7 31 52 31 7 // 12 52 127 52 12 // 7 31 52 31 7 // 2 7 12 7 2 void FrameSmooth5GaussB(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // 2 7 12 7 2 // 7 31 52 31 7 // 12 52 127 52 12 // 7 31 52 31 7 // 2 7 12 7 2 void FrameSmooth5GaussThresholdB(byte* pSrc, byte* pDst, int nW, int nH, int nThreshold) { } //----------------------------------------------------------------------------------- // pCon array (convolution coefficients) has dimension = 9 (row after row) void FrameConvolution3B(byte* pSrc, short* pDst, int nW, int nH, int* pCon) { } //----------------------------------------------------------------------------------- // pCon array (convolution coefficients) has dimension = 9 (row after row) void FrameConvolution3S(short* pSrc, short* pDst, int nW, int nH, int* pCon) { } //----------------------------------------------------------------------------------- // pCon array (convolution coefficients) has dimension = 25 (row after row) void FrameConvolution5B(byte* pSrc, short* pDst, int nW, int nH, int* pCon) { } //----------------------------------------------------------------------------------- // pCon array (convolution coefficients) has dimension = 25 (row after row) void FrameConvolution5S(short* pSrc, short* pDst, int nW, int nH, int* pCon) { } //----------------------------------------------------------------------------------- // return Sum of Absolute Differences int FrameSADB(byte* pFrm1, byte* pFrm2, int nW, int nH) { int nSAD = 0; return nSAD; } //----------------------------------------------------------------------------------- // return Sum of Absolute Differences double FrameSADS(short* pFrm1, short* pFrm2, int nW, int nH) { double fSAD = 0; return fSAD; } //----------------------------------------------------------------------------------- // v= 255 - v void FrameNegativeB(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // if (vnHigh) v=0 void FrameCutsB(byte* pSrc, byte* pDst, int nW, int nH, int nLow, int nHigh) { } //----------------------------------------------------------------------------------- // (nLow,nHigh) to (0,255) void FrameRenormB(byte* pSrc, byte* pDst, int nW, int nH, int nLow, int nHigh) { } //----------------------------------------------------------------------------------- void FrameMedianFilter3B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- void FrameMedianFilter5B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // -1 -1 -1 // -1 16 -1 // -1 -1 -1 void FrameSharpenFilter3B(byte* pSrc, short* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // -1 -1 -1 -1 -1 // -1 -2 -2 -2 -1 // -1 -2 64 -2 -1 // -1 -2 -2 -2 -1 // -1 -1 -1 -1 -1 void FrameSharpenFilter5B(byte* pSrc, short* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=min from window 3x3 void FrameMinFilter3B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=max from window 3x3 void FrameMaxFilter3B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=(min+max)/2 from window 3x3 void FrameMinMaxFilter3B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=min from window 5x5 void FrameMinFilter5B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=max from window 5x5 void FrameMaxFilter5B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- // v=(min+max)/2 from window 5x5 void FrameMinMaxFilter5B(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- void FrameMirrorXB(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- void FrameMirrorYB(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- void FrameMirrorRotate90LeftB (byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- void FrameMirrorRotate90RightB(byte* pSrc, byte* pDst, int nW, int nH) { } //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- int ReadPGM(char* file_name, byte** ppImg, int* pnWidth, int* pnHeight) { char buf[512]; FILE* pInpFile = fopen(file_name,"rb"); if( pInpFile==NULL) return 1; fgets(buf,510,pInpFile); // "P5" fgets(buf,510,pInpFile); // "#comments" fgets(buf,510,pInpFile); // "width height" sscanf(buf,"%d %d", pnWidth, pnHeight); printf("width=%d height=%d\n", *pnWidth, *pnHeight); fgets(buf,510,pInpFile); // "MaxColor" *ppImg = malloc((*pnWidth) * (*pnHeight)); fread(*ppImg, 1, (*pnWidth) * (*pnHeight), pInpFile); fclose(pInpFile); return 0; } //----------------------------------------------------------------------------------- void WritePGM(char* file_name, byte* pImg, int nWidth, int nHeight) { FILE* img_file= fopen(file_name, "wb"); fprintf( img_file, "P5\n#\n%d %d\n255\n", nWidth, nHeight ); fwrite( pImg, 1, nWidth * nHeight, img_file); fclose(img_file); } //----------------------------------------------------------------------------------- // read ppm image file int PpmImageFileRead(char* filename, byte** ppPic, int* pnW, int* pnH) { FILE* pInpFile; char buf[512]; // open image file pInpFile=fopen(filename,"rb"); if( pInpFile==NULL) return 1; fgets(buf,510,pInpFile); // "P6" fgets(buf,510,pInpFile); // "#comments" fgets(buf,510,pInpFile); // "width height" sscanf(buf,"%d %d", pnW, pnH); printf("%d %d\n", *pnW, *pnH); fgets(buf,510,pInpFile); // "MaxColor" *ppPic = malloc(3 * (*pnW) * (*pnH)); fread(*ppPic, 1, (3 * (*pnW) * (*pnH)), pInpFile); fclose(pInpFile); return 0; } //----------------------------------------------------------------------------------- // write ppm image file int PpmImageFileWrite(char* filename, byte* pPic, int nWidth, int nHeight) { FILE* pOutFile; pOutFile=fopen(filename,"wb"); fprintf( pOutFile, "P6\n#\n%d %d\n255\n", nWidth, nHeight ); fwrite(pPic, 1, 3 * nWidth * nHeight, pOutFile); fclose(pOutFile); return 0; } //----------------------------------------------------------------------------------- void YCC420ToRGB(byte* pLu, byte* pCb, byte* pCr, int nW, int nH, byte* pR, byte* pG, byte* pB) { int i, j, k ,l; int acc; for(i=0; i255) acc = 255; pR[k] = acc; acc = (double) pLu[k] - 0.344*(pCb[l]-128.) - 0.714*(pCr[l]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pG[k] = acc; acc = (double) pLu[k] + 1.772*(pCb[l]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pB[k] = acc; } } //----------------------------------------------------------------------------------- void YUV420ToRGB(byte* pY, byte* pU, byte* pV, int nW, int nH, byte* pR, byte* pG, byte* pB) { int i, j, k ,l; int acc; for(i=0; i255) acc = 255; pR[k] = acc; acc = (double) pY[k] - 0.394*(pU[l]-128.) - 0.581*(pV[l]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pG[k] = acc; acc = (double) pY[k] + 2.028*(pU[l]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pB[k] = acc; } } //----------------------------------------------------------------------------------- // 4:4:4 void TransformRGBtoLuCbCr(byte* pRed, byte* pGreen, byte* pBlue, byte* pLuma, byte* pChromaB, byte* pChromaR, int nWidth, int nHeight) { int i; int size = nWidth * nHeight; int acc; for(i=0; i255) acc = 255; pChromaB[i] = acc; acc = 0.713*pRed[i] - 0.713*pLuma[i] + 128.; if(acc<0) acc = 0; else if(acc>255) acc = 255; pChromaR[i] = acc; } } //----------------------------------------------------------------------------------- // 4:4:4 void TransformLuCbCrToRGB(byte* pLuma, byte* pChromaB, byte* pChromaR, byte* pRed, byte* pGreen, byte* pBlue, int nWidth, int nHeight) { int i; int size = nWidth * nHeight; int acc; for(i=0; i255) acc = 255; pRed[i] = acc; acc = (double) pLuma[i] - 0.344*(pChromaB[i]-128.) - 0.714*(pChromaR[i]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pGreen[i] = acc; acc = (double) pLuma[i] + 1.772*(pChromaB[i]-128.); if(acc<0) acc = 0; else if(acc>255) acc = 255; pBlue[i] = acc; } } //----------------------------------------------------------------------------------- // make (r,g,b) image from R,G,B components void MakeRGBfromComponents(byte* pRGB, byte* pRed, byte* pGreen, byte* pBlue, int nWidth, int nHeight) { int i,ii; int nn = nWidth*nHeight; for(i=0; i