Page 1 of 1

Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 19th, 2024, 6:44 pm
by pierrelabreche
In the screenshot below, a gray wedge is equalized flat.
The blacks are not equalized as expected. The oroginal black ( 0% ) is brightened to an HSV-V value of 8,6.
2024-06-19 Equalize results on  step wedge.jpg
2024-06-19 Equalize results on step wedge.jpg (68.26 KiB) Viewed 848 times
Equalized step wedge output
2024-06-19 Equalize step wedge.jpg
2024-06-19 Equalize step wedge.jpg (18.94 KiB) Viewed 848 times
Script is attached
2024-06-19 Equalize step wedge.jpg.script
(1.37 KiB) Downloaded 52 times

Re: Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 19th, 2024, 7:17 pm
by jsachs
There are spikes in the input image histogram at white and black, presumably due to the borders between the patches. If you use a linear gradient as the input image instead I think you will see what your were expecting.

Re: Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 19th, 2024, 8:38 pm
by pierrelabreche
The large black patch ( 0% ) should be taken into account in the equalization process. The value of pure black in the output image, i.e. after equalization , should remain pure black.

The spikes are due to the uniform patches and white text.

The resulting range of values appears biased away from black.

Will experiment later with gradient.

Re: Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 20th, 2024, 6:50 am
by jsachs
>>The large black patch ( 0% ) should be taken into account in the equalization process. The value of pure black in the output image, i.e. after equalization , should remain pure black.

That's not how it works. The first non-zero output histogram value is biased toward white to reduce the excess amount of pure black from the labels and borders in the input image.
equal.jpg
equal.jpg (8.49 KiB) Viewed 836 times
When you test with Linear Gradient, make sure you set the transition between black and white to Line and not Sine.

Re: Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 20th, 2024, 3:45 pm
by pierrelabreche
jsachs wrote: June 20th, 2024, 6:50 am The first non-zero output histogram value is biased toward white to reduce the excess amount of pure black from the labels and borders in the input image.

I did one more experiment with the grey step wedge, whereby I applied a gray curve to the input image so that it is not pure black, just to see if pure black was especially ignored.
2024-06-20 Equalize results on  step wedge, after brightening to HSV-V 2.jpg
2024-06-20 Equalize results on step wedge, after brightening to HSV-V 2.jpg (68.24 KiB) Viewed 826 times
Quoting the help for Equalize:
Standard histogram equalization works by trying to adjust the image to a flat curve as illustrated below. This causes each tonal values in the output image to be roughly equally represented,
The Equalize curve is flat, that is, all tones between pure black and pure white are desired to be equally distributed. The output histogram is showing that tonal values in the output image are not equally represented. The black tones which are largely present, as shown with the left peak in the input histogram, are absent in the output image's tonal range.

The experiment shows that even with dark grey ( HSV-V = 2 ), the output histogram remains tilted towards whites.
Gradient experiments to follow.

Re: Issue : Equalize transformation unexpectedly brightens the blacks

Posted: June 27th, 2024, 1:32 pm
by pierrelabreche
jsachs wrote: June 20th, 2024, 6:50 am >>
That's not how it works. The first non-zero output histogram value is biased toward white to reduce the excess amount of pure black from the labels and borders in the input image.
...
When you test with Linear Gradient, make sure you set the transition between black and white to Line and not Sine.
I experimented using a test pattern consisting of a a pure gradient. The results are identical after equalization, as expected.

I then created another experiment with a pattern involving all tones by applying the linear gradient to a Star test pattern, using Hard light.
The resulting pattern is well-balanced : it consists of light and dark tones instead of the pure black and white original star pattern.
The results are shown below.
The equalize transformation treats differently the light and the dark tones. Probing the pure black shows it is substantially lightened, whereas the whites are not darkened to the same degree. There is a noticeable step tonal change at the 0 and 180 degrees rays.
2024-06-27 PWP8  Equalize Test pattern Star with gradient-hard light-screenshot v2.jpg
2024-06-27 PWP8 Equalize Test pattern Star with gradient-hard light-screenshot v2.jpg (153.58 KiB) Viewed 746 times