[Wavelet-commit] Wavelet Image.cc,1.19,1.20
Status: Beta
Brought to you by:
herbert
From: Johan H. E. <bo...@us...> - 2005-07-14 17:06:30
|
Update of /cvsroot/wavelet/Wavelet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20708 Modified Files: Image.cc Log Message: Image class: Gamma correction now also has ability to work on other predefined normalization ranges oppose to default range of (0..255.). Index: Image.cc =================================================================== RCS file: /cvsroot/wavelet/Wavelet/Image.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Image.cc 13 Jul 2005 15:20:30 -0000 1.19 --- Image.cc 14 Jul 2005 17:06:18 -0000 1.20 *************** *** 221,225 **** void Image::gammaCorrection (double factor, int yoffs, int xoffs, ! int ysize, int xsize) { if (yoffs < 0 || yoffs >= rows ()) --- 221,225 ---- void Image::gammaCorrection (double factor, int yoffs, int xoffs, ! int ysize, int xsize, int norm) { if (yoffs < 0 || yoffs >= rows ()) *************** *** 245,276 **** coeff min = smin (yoffs, xoffs, toY, toX); coeff max = smax (yoffs, xoffs, toY, toX); - coeff amin = fabs (min); - int iMin = tools_coeff2int (min - 0.5); - int iMax = tools_coeff2int (max + 0.5); - coeff norm = 255.0; - coeff lift = 0.0; - coeff cRange = max - min; - int tableSize = (int)(cRange + 0.5); ! coeff *replaceTable = NEW (coeff[tableSize]); ! if (iMin >= 0 && iMax <= 255) ! { ! norm = cRange; ! } ! if (iMin < 0) { ! lift = amin; } ! replaceTable[0] = 0.0; ! for (int i = 1; i < tableSize; i++) ! { ! replaceTable[i] = norm * pow ((coeff)i / norm, 1.0 / factor) - lift; ! } ! for (int i = 0; i < m_xysize; i++) { ! to (i , replaceTable[(int)(at (i) + lift)]); } --- 245,272 ---- coeff min = smin (yoffs, xoffs, toY, toX); coeff max = smax (yoffs, xoffs, toY, toX); ! int iMin = tools_coeff2int (min - 0.5); ! iMin = MIN (0,iMin); ! ! int iMax = tools_coeff2int (max); ! iMax = MAX (norm,iMax); ! ! norm = iMax-iMin; ! coeff normCoeff = (coeff)norm; ! coeff * replaceTable = replaceTable = NEW (coeff[norm+1]); ! for (int i = 0; i <= norm; i++) { ! replaceTable[i] = tools_coeff2int ! (norm * pow ((coeff)(i+iMin) / normCoeff, 1.0 / factor)); } ! for (int y = yoffs; y < toY; y++) { ! for ( int x = xoffs; x < toX ; x++ ) ! { ! to (y, x, replaceTable[(int)(at (y,x)+iMin)]); ! } } *************** *** 279,284 **** double ! Image::gammaCorrectionAuto ( int rows , int columns , int yoffs, ! int xoffs, int ysize, int xsize) { if ((yoffs < 0) || (yoffs >= this->rows ())) --- 275,280 ---- double ! Image::gammaCorrectionAuto ( int rows, int columns, int yoffs, ! int xoffs, int ysize, int xsize, int norm) { if ((yoffs < 0) || (yoffs >= this->rows ())) *************** *** 354,358 **** double gammaContrast = 1 - ((float)(max - min) / (max + min)); ! gammaCorrection (1.0 / gammaContrast , yoffs , xoffs , ysize , xsize); return gammaContrast; --- 350,354 ---- double gammaContrast = 1 - ((float)(max - min) / (max + min)); ! gammaCorrection (1.0 / gammaContrast , yoffs , xoffs , ysize , xsize, norm); return gammaContrast; |