Page 1 of 1
How to smooth the hue channel?
Posted: 2010-10-07T01:34:24-07:00
by baruchel
Hi, I need to smooth the hue channel (after HSL decomposition), but of course there may be an issue with the angular meaning of the data (because 0 and 1 are the same thing in this case). Do you see some trick for doing such a thing with ImageMagick? Regards.
Re: How to smooth the hue channel?
Posted: 2010-10-07T06:12:22-07:00
by anthony
I know of no trick to smooth Hue channel such that the 'cycle' is smoothed properly.
Currently even just finding the correct color difference, in a Hue enabled colorspace goes wrong, as can be seen in
http://www.imagemagick.org/Usage/quantize/#quantize
I could use a good formula for hue handling in the FX gradient generation (last example)...
http://www.imagemagick.org/Usage/canvas ... nt_complex
Re: How to smooth the hue channel?
Posted: 2010-10-09T18:12:28-07:00
by fmw42
Create a mask image that is the standard deviation in the neighborhood of each pixel, threshold it so that if the standard deviation is too high make it black and if less than the threshold, make it white. Then use this as a mask between the original hue channel and a blurred version of the hue channel so that it uses the original when the mask is black and the blurred image where the mask is white. That should avoid the area in the hue image where you have neighboring values near 0 and near 1, so they are not averaged.
The standard deviation can be computed from the following formula
std=sqrt( average of image squared minus square of average image)
convert image \( -clone 0 -clone 0 -compose multiply -composite -blur radiusxsigma \) \
\( -clone 0 -blur radiusxsigma -function polynomial "1 0 0" \) \
-delete 0 +swap -compose minus -composite -evaluate pow 0.5 stdimage
Re: How to smooth the hue channel?
Posted: 2010-10-09T23:01:15-07:00
by anthony
Avoiding the area where hue changes suddenly is not the problem. Though it may be part of the solution.
Smoothing across the hue discontinuity correctly is the problem.
That is averaging (blurring or mixing) slightly green red (Hue=6%) and slighly green red (Hue=98%) should become a redder-red (say Hue=2%).
But doing this without taking into account the hue cyclic nature results in a Cyan color (Hue=53%), which is Obviously nothing like the original two red colors.
This is the problem with Hue!