8-bit to RGB changes data?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

8-bit to RGB changes data?

Ed Siefker
I have a stack of three monochrome 8-bit images that I need
to convert to RGB so that they stay the right color when I
save them as a tiff.  When I hover over the brightest part of
the image, I get values in the 60s.  After selecting Image->
Type->RGB Color, that area is saturated at 255.

What's going on here?  When you convert a monochrome to
a three channel image, shouldn't you just preserve the data in
the monochrome and add two channels full of zeros?
-Ed

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 8-bit to RGB changes data?

Swayne, Theresa C.
Hi Ed,

The RGB conversion in ImageJ scales the output pixel values according to the display contrast. Anything above the white level (max. displayed value) will become 255.

Perhaps you adjusted the contrast, or perhaps the images were autoscaled when you opened them.

To check this: Image > Adjust > Brightness & Contrast, click Set, and set the minimum and maximum displayed value to 0 and 255 respectively. Then convert and see if you get the same issue.

Hope this helps,
Theresa


On Apr 12, 2016, at 1:19 PM, Ed Siefker <[hidden email]<mailto:[hidden email]>> wrote:

I have a stack of three monochrome 8-bit images that I need
to convert to RGB so that they stay the right color when I
save them as a tiff.  When I hover over the brightest part of
the image, I get values in the 60s.  After selecting Image->
Type->RGB Color, that area is saturated at 255.

What's going on here?  When you convert a monochrome to
a three channel image, shouldn't you just preserve the data in
the monochrome and add two channels full of zeros?
-Ed

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

------------------------------------
Theresa Swayne, Ph.D.
Manager
Confocal and Specialized Microscopy Shared Resource<http://hiccc.columbia.edu/research/sharedresources/confocal>

Herbert Irving Comprehensive Cancer Center
Columbia University Medical Center
1130 St. Nicholas Ave., Room 222A
New York, NY 10032
Phone: 212-851-4613
[hidden email]<mailto:[hidden email]>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 8-bit to RGB changes data?

Michael Schmid-3
In reply to this post by Ed Siefker
Hi Ed,

ImageJ maps the displayed range to the full output range if you have
'Scale when converting' enabled in Edit>Options>Conversions.

So if the display range (see Image>Adjust>Brightness&Contrast) of your
8-bit image is between 0 and 60, the value 60 and everything above is
white on the screen.  Then, also the RGB image will be white in these
places.

This behavior is quite handy when converting images with a color lookup
table (LUT) to RGB:  What you see is what you get.

[By the way, an RGB image has 0-255 for red, green and blue, so white is
255 for all three channels. White would correspond to 255,0,0 for YUV,
but this is not a native type in ImageJ]


Michael
________________________________________________________________
On 2016-04-12 19:19, Ed Siefker wrote:

> I have a stack of three monochrome 8-bit images that I need
> to convert to RGB so that they stay the right color when I
> save them as a tiff.  When I hover over the brightest part of
> the image, I get values in the 60s.  After selecting Image->
> Type->RGB Color, that area is saturated at 255.
>
> What's going on here?  When you convert a monochrome to
> a three channel image, shouldn't you just preserve the data in
> the monochrome and add two channels full of zeros?
> -Ed
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 8-bit to RGB changes data?

Herbie
In reply to this post by Ed Siefker
Good day Ed,

not perfectly sure what you are doing.

"When I hover over the brightest part of
the image [...]"

Which image? The first of your stack?

"When you convert a monochrome to a three channel image [...]"

How do you convert a (single?) monochrome image to a stack?
Do you just triplicate the same image for this purpose?

Perhaps you could run the following example macro and tell us where the
problem occurs. Paste the following lines in an empty macro window
        "Plugins > New > Macro"
and run the macro.

//=====================================================
newImage("Red", "8-bit ramp", 128, 128, 1);
run("Duplicate...", "title=Green");
run("Rotate 90 Degrees Right");
run("Duplicate...", "title=Blue");
run("Rotate 90 Degrees Right");
run("Images to Stack", "name=Stack title=[] use keep");
run("RGB Color");
//=====================================================

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
Am 12.04.16 um 19:19 schrieb Ed Siefker:

> I have a stack of three monochrome 8-bit images that I need
> to convert to RGB so that they stay the right color when I
> save them as a tiff.  When I hover over the brightest part of
> the image, I get values in the 60s.  After selecting Image->
> Type->RGB Color, that area is saturated at 255.
>
> What's going on here?  When you convert a monochrome to
> a three channel image, shouldn't you just preserve the data in
> the monochrome and add two channels full of zeros?
> -Ed
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 8-bit to RGB changes data?

Ed Siefker
In reply to this post by Michael Schmid-3
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?

On Tue, Apr 12, 2016 at 12:47 PM, Michael Schmid
<[hidden email]> wrote:

> Hi Ed,
>
> ImageJ maps the displayed range to the full output range if you have 'Scale
> when converting' enabled in Edit>Options>Conversions.
>
> So if the display range (see Image>Adjust>Brightness&Contrast) of your 8-bit
> image is between 0 and 60, the value 60 and everything above is white on the
> screen.  Then, also the RGB image will be white in these places.
>
> This behavior is quite handy when converting images with a color lookup
> table (LUT) to RGB:  What you see is what you get.
>
> [By the way, an RGB image has 0-255 for red, green and blue, so white is 255
> for all three channels. White would correspond to 255,0,0 for YUV, but this
> is not a native type in ImageJ]
>
>
> Michael
> ________________________________________________________________
>
> On 2016-04-12 19:19, Ed Siefker wrote:
>>
>> I have a stack of three monochrome 8-bit images that I need
>> to convert to RGB so that they stay the right color when I
>> save them as a tiff.  When I hover over the brightest part of
>> the image, I get values in the 60s.  After selecting Image->
>> Type->RGB Color, that area is saturated at 255.
>>
>> What's going on here?  When you convert a monochrome to
>> a three channel image, shouldn't you just preserve the data in
>> the monochrome and add two channels full of zeros?
>> -Ed
>>
>> --
>> 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
Reply | Threaded
Open this post in threaded view
|

Enhance Contrast not idempotent? (was: Re: 8-bit to RGB changes data?)

Michael Schmid-3
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
Reply | Threaded
Open this post in threaded view
|

Re: Enhance Contrast not idempotent? (was: Re: 8-bit to RGB changes data?)

Ed Siefker
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
Reply | Threaded
Open this post in threaded view
|

Re: Enhance Contrast not idempotent?

Michael Schmid-3
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