I want to modify luminance values of color image pixels. The modification rules are as follows:
Assumption: Luminance values are normalised in [0, 1], 1 = White
- If a chosen pixel's luminance value is above a threshold (say thresh=0.5, pixel luminance value = 0.8), it's changed to a lower value (say 0.3), so that when the image is binarised, that pixel is shown as a black pixel.
- Similarly, if a chosen pixel's luminance value is below a threshold, the luminance is increased so that it binarises as white.
I have tried MATLAB's rgb2hsv()
and hsv2rgb()
functions to convert an RGB image to HSV, extract the luminance channel, modify it, and change the image back to RGB. But the results are not what I need.
What I need is:
- If a bright red pixel's luminance is decreased, it should become dark red, so it binarises to black.
- If a white pixel's luminance is decreased, it should become black.
- If a black pixel's luminance is increased, it should become white.
I have following issues/questions:
- When I decrease the luminance of a white pixel, it turns red instead of black.
- Is it possible to achieve the above mentioned goals without modifying any other channels of the HSV image, like Hue/Chrominance?
- Is the conversion between RGB and HSV loss-less?
- What would be an ideal way to achieve this?