Alter image luminance without changing colors

image-processing

134 просмотра

2 ответа

I'm interested in equalizing a color image. What I'm doing is to start with an RGB image and convert it to YIQ values according to this article. After that I can obtain a greyscale version of the image by considering luminance levels given by Y. Applying an algorithm to that greyscale image, I can get a more or less equalized version of the greyscale version of the original image. I'd like to produce a new RGB image that preserves the colors of the original one and corrects the luminance values, to get a luminance-equalized RGB version of the original image.

First, I tried to convert the YIQ values back to RGB but considering for Y the modified values after equalization. With this approach I got RGB values out of [0,1].

Because that first approach did not work, I tried to do the following with a relative level of success. For each pixel, if Y' is the luminance level after equalizating and Y the original luminance value, I consider the new RGB values given by R' = (Y'/Y) R, G' = (Y'/Y) G and B' = (Y'/Y) B. That is, I escalated the luminance level preserving proportionality in the distribution of RGB components.

Even though the second approach worked, I have the problem that some of the colors in the original image look different after the equalization. This effect is more or less percievable depending on the original image. My question is, what is a good, color-preserving approach for transforming the original RGB image into a new one with the luminance values corrected?

Note that in the second method(btw, the only one that worked), I have to replace the (Y'/Y) in the formulas by the minumum between (Y'/Y) and the maximum of (1/R), (1/G) and (1/B), so I don't get above 1 in any component. Of course, this is another drawback because for some pixels I can't get the luminance level calculated in the greyscale equalization step.

Автор: ORerwannabe Источник Размещён: 08.11.2019 11:29

Ответы (2)


0 плюса

You don't metion your OS, your software environment nor provide any images, so I'll suggest an option using ImageMagick just at the command-line. It is installed on most Linux distros and available for OSX and Windows with Python, PHP, Perl, Java, C/C++ bindings too.

So, I think you want something like this:

convert input.jpg -colorspace YIQ -channel R -equalize +channel -colorspace RGB result.jpg

That says... "Convert image input.jpg to YIQ colourspace, then only operating on the first channel (R channel which is Y here), equalize that channel. Now revert to using all 3 channels and go back to RGB colourspace and save as result.jpg".

Автор: Mark Setchell Размещён: 20.08.2016 07:55

0 плюса

You can do a linear transform from the current range to the [0,1] range. Lets say now your green channel after the conversion back from Y'IQ is [gMin,gMax] then map all the values back to [0,1] range using the following linear mapping (based on this answer answer):

NewValue = ((OldValue - gMin) / (gMax - gMin))

Do this for the all the channels R,G,B.

Автор: Amitay Nachmani Размещён: 21.08.2016 05:02
Вопросы из категории :
32x32