Log in

View Full Version : linear color masking/selection


Ignus2
31st October 2006, 22:12
Hi!

I want to do something, that MaskHS does, but in a non-binary way.

Basically, I have a video, and based on that video I want to make a greyscale mask, where the brightness is proportional to the color what I want to select.

For example, I want to select yellow from an image. In the output, the greyscale image should be more white in those parts, where the original picture is close to yellow, and more black, where it is far from yellow.

How could I achieve that?

To specify what color to select, I would prefer to give the color in HSV parameters.

--
Thanks in advance!

actionman133
31st October 2006, 22:19
I'm on the way out the door, so I can only give you the method I use, but no time for scripts at the moment...

Use UtoY () and use levels to select the yellow portion of the yellow/blue channel. Only concern is that white in the image will appear as black in the mask, because white has no yellow in the U channel.

Ignus2
2nd November 2006, 00:26
Can you make it a bit more exact? How exactly did you use it?

Anyway:
I have been experimenting with RGB, HSV, HSL, HSP systems (in a small plugin) to find the "distance" between colors.
So far, I couldn't come up with a sane metric for the HS_ variants, that give the results I want.
Yet, I've found this article:
http://www.compuphase.com/cmetric.htm

The proposed metric seems to give reasonable results, and it works in RGB.

Ideas are welcome.

--
Greets,

IanB
2nd November 2006, 04:57
A refinement to actionman133's idea....
value=10 # Choose value to align Yellow along the U axis
Gamma=2.0 # Choose for selectivity
Tweak(Hue=value)
UtoY()
Levels(128, Gamma, 255, 0, 255) # Map NOT yellowness to black