From: Udi F. <udi...@us...> - 2007-03-31 22:28:20
|
Update of /cvsroot/ufraw/ufraw In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv27652 Modified Files: ufraw_developer.c Log Message: Retain some hue and saturation when clipping pixels to 0xFFFF. This is only relevant when applying positive exposure compensation, and mostly for Canon cameras where positive exposure is applied by default. Index: ufraw_developer.c =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_developer.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ufraw_developer.c 24 Mar 2007 19:49:08 -0000 1.34 --- ufraw_developer.c 31 Mar 2007 22:28:16 -0000 1.35 *************** *** 586,589 **** --- 586,619 ---- } } + gboolean clipped = FALSE; + for (c=0; c<3; c++) if (tmppix[c]>0xFFFF) clipped = TRUE; + if (clipped) { + /* When clipping to 0xFFFF, retain some saturation and hue. */ + gint64 *unclippedPix = tmppix; + int maxc, midc, minc; + MaxMidMin(unclippedPix, &maxc, &midc, &minc); + gint64 unclippedLum = unclippedPix[maxc]; + gint64 clippedLum = 0xFFFF; + gint64 unclippedSat; + if ( unclippedPix[maxc]==0 ) + unclippedSat = 0; + else + unclippedSat = 0x10000 - + unclippedPix[minc] * 0x10000 / unclippedPix[maxc]; + gint64 unclippedHue; + if ( unclippedPix[maxc]==unclippedPix[minc] ) + unclippedHue = 0; + else + unclippedHue = + (unclippedPix[midc]-unclippedPix[minc])*0x10000 / + (unclippedPix[maxc]-unclippedPix[minc]); + gint64 lum = clippedLum + (unclippedLum - clippedLum) * 1/4; + gint64 sat = unclippedSat; + gint64 hue = unclippedHue; + + tmppix[maxc] = lum; + tmppix[minc] = lum * (0x10000-sat) / 0x10000; + tmppix[midc] = lum * (0x10000-sat + sat*hue/0x10000) / 0x10000; + } } for (c=0; c<3; c++) |