Login  Register

Re: Enhance Contrast not idempotent?

Posted by Michael Schmid on Apr 13, 2016; 4:35pm
URL: http://imagej.273.s1.nabble.com/8-bit-to-RGB-changes-data-tp5016110p5016123.html

Hi Ed,

(after a short offline discussion):
It seems that you have RGB images; I had only thought about grayscale
images.

For grayscale images, changing the Brightness&Contrast (i.e., the min
and max values of the range mapped to grayscale between black and white)
only affects the display, the image data remain the same.

For RGB images, changing B&C affects the actual image data; ImageJ just
keeps a copy of the original image in the background. This behavior
stems from the old days when computers were slow and had little memory.

So, I do understand why 'Enhance Contrast' gives different values for
the first and subsequent runs, but I do not understand how it can jump
back and forth.

There seems to be a difference between single RGB images and RGB stacks
that I do not understand - if one does successive 'Enhance Contrast'
runs on a single image, one can undo only the last one. On a stack, it
seems one can go back to the original state (which is surprising;
usually there is no undo for stacks).

Michael
________________________________________________________________
On 2016-04-13 17:52, Ed Siefker wrote:

> How strange.  This is what I get running that macro:
>
> Display range is 0 to 35
> Display range is 0 to 85
> Display range is 0 to 35
> Display range is 0 to 85
> Display range is 0 to 35
>
>
> On Wed, Apr 13, 2016 at 8:28 AM, Michael Schmid <[hidden email]> wrote:
>> Hi Ed,
>>
>> sorry, I cannot reproduce this. Running 'Enhance contrast' repeatedly always
>> results in the same setting of the display range. Try this macro:
>>
>> for (i=0; i<5; i++) {
>>    run("Enhance Contrast...", "saturated=0.1");
>>    getMinAndMax(min, max);
>>    print("Display range is "+min+" to "+max);
>> }
>>
>> The 'Auto' button of the B&C panel is not idempotent: when pressing it more
>> than once, the display range is narrowed (a very nice feature!)
>>
>> Also, 'Enhance Contrast' is not idempotent when you select the checkbox to
>> equalize the histogram (this modifies the image data).
>>
>> Michael
>> ________________________________________________________________
>> Michael Schmid                    email: [hidden email]
>> On 2016-04-12 22:08, Ed Siefker wrote:
>>>
>>> Thanks, running 'setMinAndMax(0, 255)' before the conversion seems to
>>> work.
>>>
>>> This brings me to another question.  Why isn't 'Enhance Contrast'
>>> idempotent?
>>> Repeated application of Enhance Contrast with the same parameters
>>> e.g. run("Enhance Contrast...", "saturated=0.1");
>>> results in repeated changing of the image.
>>>
>>> Given a histogram, isn't there exactly one value above which 0.1% of
>>> values are
>>> found?
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html