SVN commit 512021 by mwiesweg:
digikam from trunk: rounding error of BCG modifier With the current algorithm, even setting a gamma of 1.0 would create changes, (x / 255.0) * 255.0 might be slightly less than x, so casting this value to int would result in an error of 1. I hope using the round() function is a correct fix for this, at least the 1.0 value now creates a proper x=y mapping. M +2 -2 bcgmodifier.cpp --- trunk/extragear/graphics/digikam/libs/dimg/filters/bcgmodifier.cpp #512020:512021 @@ -152,7 +152,7 @@ for (int i=0; i<65536; i++) { - val2 = (int)(pow(((double)d->map16[i] / 65535), (1 / val)) * 65535); + val2 = (int)round(pow(((double)d->map16[i] / 65535), (1 / val)) * 65535); if (d->overIndicator && val2 > 65535) d->map16[i] = -1; else @@ -161,7 +161,7 @@ for (int i=0; i<256; i++) { - val2 = (int)(pow(((double)d->map[i] / 255), (1 / val)) * 255); + val2 = (int)round(pow(((double)d->map[i] / 255), (1 / val)) * 255); if (d->overIndicator && val2 > 255) d->map[i] = -1; else ------------------------------------------------------- _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Le Mardi 21 Février 2006 16:37, Marcel Wiesweg a écrit :
> SVN commit 512021 by mwiesweg: > > digikam from trunk: rounding error of BCG modifier > > With the current algorithm, even setting a gamma of 1.0 would create > changes, (x / 255.0) * 255.0 might be slightly less than x, so casting > this value to int would result in an error of 1. > I hope using the round() function is a correct fix for this, > at least the 1.0 value now creates a proper x=y mapping. > > Fine for me. If you have any time, HSLModifier don't work properly with 16 bits image (i suspect a problem too with 8 bits image). Can you take a look my comments in source code and give me your viewpoint ? Thanks in advance Gilles Nota : HSL tool is the last one from core plugin to port in 16 bits (:=)))... _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
> > digikam from trunk: rounding error of BCG modifier
> > > > With the current algorithm, even setting a gamma of 1.0 would create > > changes, (x / 255.0) * 255.0 might be slightly less than x, so casting > > this value to int would result in an error of 1. > > I hope using the round() function is a correct fix for this, > > at least the 1.0 value now creates a proper x=y mapping. > > Fine for me. > > If you have any time, HSLModifier don't work properly with 16 bits image (i > suspect a problem too with 8 bits image). > > Can you take a look my comments in source code and give me your viewpoint ? As to 16 bit, there is an integer overflow in setLightness and setSaturation, 65535^2 = 2^32, so something like (i * (65535 + value) will wrap around for larger values of i. I think I have a fix for this, but now I have managed to break it even more thoroughly, for 8bit as well :-) I will work on this tomorrow. Marcel > > Thanks in advance > > Gilles > > Nota : HSL tool is the last one from core plugin to port in 16 bits > (:=)))... > > _______________________________________________ > Digikam-devel mailing list > [hidden email] > https://mail.kde.org/mailman/listinfo/digikam-devel Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Le Mercredi 22 Février 2006 23:58, Marcel Wiesweg a écrit :
> > > digikam from trunk: rounding error of BCG modifier > > > > > > With the current algorithm, even setting a gamma of 1.0 would create > > > changes, (x / 255.0) * 255.0 might be slightly less than x, so casting > > > this value to int would result in an error of 1. > > > I hope using the round() function is a correct fix for this, > > > at least the 1.0 value now creates a proper x=y mapping. > > > > Fine for me. > > > > If you have any time, HSLModifier don't work properly with 16 bits image > > (i suspect a problem too with 8 bits image). > > > > Can you take a look my comments in source code and give me your viewpoint > > ? > > As to 16 bit, there is an integer overflow in setLightness and > setSaturation, 65535^2 = 2^32, so something like (i * (65535 + value) will > wrap around for larger values of i. > I think I have a fix for this, but now I have managed to break it even more > thoroughly, for 8bit as well :-) > I will work on this tomorrow. Ok. thanks (:=))) Gilles _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |