Hello Tom -
If you need to average a single ROI that contains a wide range of
colors – the whole rainbow, so to speak – this will be a tricky issue
to deal with. (But I have the sense that you don’t want or need to
do this – that individual ROIs will be more-or-less the same hue
So, for limited-hue-range ROIs, this will only be a problem when
you’re averaging over an ROI whose hue is in the red region where
the hue angle wraps around from 360 back to 0 degrees.
It would be relatively straightforward to write a script (or plugin)
that correctly calculates a “wrap-around” angular hue average.
If you don’t wish to go the script route, you could, for ROIs that
are reddish, first rotate the hue, calculate the average, and then
rotate back. I don’t believe that ImageJ has a built-in hue-rotation
function, but this HueRotation.txt macro seems to be blessed by
the ImageJ gods.
(To automate this so that you don’t have to flag reddish ROIs by
hand, I suspect that you could rotate-average-derotate for angles
of 0 (no-op), 120, and 240 degrees, and then use the average hue
that wins a best two-out-of-three vote as your result.)
I’m not aware of any ImageJ tool that will automatically and
quantitatively perform a color correction for you. However, you
Image > Adjust > Color Balance... by hand
on your RGB image before converting to hue space.