Thread: [Wavelet-commit] Wavelet Image.cc,1.16,1.17
Status: Beta
Brought to you by:
herbert
From: Herbert M. D. <he...@us...> - 2005-07-13 13:15:14
|
Update of /cvsroot/wavelet/Wavelet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29349 Modified Files: Image.cc Log Message: Changes to Image::gammaCorrection(), it should now be faster even if the color range is beyond [0..255]. Removed CRs from line ends in pgmequalize.cc. Index: Image.cc =================================================================== RCS file: /cvsroot/wavelet/Wavelet/Image.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Image.cc 13 Jul 2005 12:13:22 -0000 1.16 --- Image.cc 13 Jul 2005 13:15:06 -0000 1.17 *************** *** 250,273 **** coeff norm = 255.0; coeff lift = 0.0; ! if (iMin < 0 || iMax > 255) { norm = max - min; } - else - { - coeff * replaceTable = new coeff[256]; - replaceTable[0] = 0.0; - for ( int i = 1;i < 256;i++ ) - { - replaceTable[i] = norm * pow ((coeff)i / norm, 1.0 / factor); - } - for ( int i = 0;i < m_xysize; i++) - { - to ( i , replaceTable[(int)at(i)] ); - } - DELETE ( replaceTable ); - return; - } if (iMin < 0) --- 250,259 ---- coeff norm = 255.0; coeff lift = 0.0; + static coeff replaceTable[256]; ! if (iMin >= 0 && iMax <= 255) { norm = max - min; } if (iMin < 0) *************** *** 276,286 **** } ! for (int y = yoffs; y < toY; y++) { ! for (int x = xoffs; x < toX; x++) ! { ! to (y, x, ! norm * pow ((at (y, x) + lift) / norm, 1.0 / factor) - lift); ! } } } --- 262,273 ---- } ! replaceTable[0] = 0.0; ! for (int i = 1; i < (int)sizeof (replaceTable); 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)]); } } *************** *** 290,294 **** int xoffs, int ysize, int xsize) { ! if ( (yoffs < 0) || (yoffs >= this->rows() ) ) { yoffs = 0; --- 277,281 ---- int xoffs, int ysize, int xsize) { ! if ((yoffs < 0) || (yoffs >= this->rows ())) { yoffs = 0; *************** *** 313,329 **** int subX = toX - xoffs; ! columns = MIN(subX,columns); ! rows = MIN(subY,rows); ! while ( ( subX % columns ) != 0 ) { columns--; } ! while ( ( subY % rows ) != 0 ) { rows--; } ! coeff * average = new coeff[rows*columns]; int width = subX / columns; --- 300,316 ---- int subX = toX - xoffs; ! columns = MIN (subX,columns); ! rows = MIN (subY,rows); ! while ((subX % columns) != 0) { columns--; } ! while ((subY % rows) != 0) { rows--; } ! coeff * average = NEW (coeff[rows*columns]); int width = subX / columns; *************** *** 338,356 **** // Average pixel value of the local area average[iy+(ix*rows)] = saverage (y , x, y + width, x + height); ! if ( !ix && !iy ) { // i.e. first loop ! min = average[iy+(ix*rows)]; ! max = average[iy+(ix*rows)]; } else { ! if (min > average[iy+(ix*rows)] ) { ! min = average[iy+(ix*rows)]; } ! else if (max < average[iy+(ix*rows)] ) { ! max = average[iy+(ix*rows)]; } } --- 325,343 ---- // Average pixel value of the local area average[iy+(ix*rows)] = saverage (y , x, y + width, x + height); ! if (!ix && !iy) { // i.e. first loop ! min = average[iy + (ix * rows)]; ! max = average[iy + (ix * rows)]; } else { ! if (min > average[iy + (ix * rows)]) { ! min = average[iy + (ix * rows)]; } ! else if (max < average[iy + (ix * rows)]) { ! max = average[iy + (ix * rows)]; } } *************** *** 358,366 **** } ! DELETE(average); double gammaContrast = 1 - ((float)(max - min) / (max + min)); ! gammaCorrection ( 1.0/gammaContrast , yoffs , xoffs , ysize , xsize ); return gammaContrast; --- 345,353 ---- } ! DELETE (average); double gammaContrast = 1 - ((float)(max - min) / (max + min)); ! gammaCorrection (1.0 / gammaContrast , yoffs , xoffs , ysize , xsize); return gammaContrast; *************** *** 391,398 **** } ! int cRange = (endH+1) - startH; bool lifted = false; ! if ( lifted = (startH < 0) ) { for (int y = yoffs; y < toY; y++) --- 378,385 ---- } ! int cRange = (endH + 1) - startH; bool lifted = false; ! if (lifted = (startH < 0)) { for (int y = yoffs; y < toY; y++) *************** *** 401,405 **** { // int temp = tools_coeff2int (at (y, x)); ! to (y, x, at (y, x) - startH ); // int newint = at (y,x); // ASSERT ( (at (y,x) >= 0) && (at (y,x) <= cRange) ); --- 388,392 ---- { // int temp = tools_coeff2int (at (y, x)); ! to (y, x, at (y, x) - startH); // int newint = at (y,x); // ASSERT ( (at (y,x) >= 0) && (at (y,x) <= cRange) ); |