1. Logarithmic transformation realizes the function of gray scale and compression of image. It expands the low gray value and compresses the high gray value, which makes the gray distribution of the image more conform to the human visual characteristics.
/******************************************************************************* function: Logarithmic transformation function * Parameter: pDst output The pixel array of the image * Parameters: PSRC The original image's pixel array * parameters: nwidth Original image Width * parameter: nheight original image Height * parameter: A control parameter, indicating the upper and lower offset of the curve * Parameter: B control parameter, which indicates how curved the curve is. Note: This function is also suitable for color graphs ****************************************************************** ************/intLogtrans (byte* pDst, byte* PSRC,intNwidth,intNheight,DoubleADoubleBB) { if(!PSRC | |!pDst) { returnexit_failure; } //mapping table for values after 256 grayscale transformationsBYTE map[ the]; //temporary values after saving an operation Doubledtemp; intI, J; for(i =0; I < the; i++) { //calculates the value after the current pixel transformDtemp = log (Double) i +1.0)/b +A; //If the bounds modify its value if(Dtemp <0) Dtemp=0.0; Else if(Dtemp >255) Dtemp=255; //RoundingMap[i] =int(Dtemp +0.5); } for(i =0; I < nwidth * nheight; i++) { for(j =0; J <4; J + +) Pdst[i*4+J] = map[psrc[i*4+J]]; } returnexit_success;}
Image processing (image inversion, logarithmic transformation, power transformation, piecewise linear transformation)