Converting 8-bit Grey Scale

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting 8-bit Grey Scale

Sebastian Baumbach-2
Hey All,

I have analyzed pressure sensitive film using imageJ.  I am using  
several processing steps and finally receive a 8-bit grey scale  
image.  I am analyzing the pressure using the grey values which I  
receive through the histogram tool embedded in ImageJ.  0 equals black  
and 2 white 55.

To make the correlation between grey values and pressure more  
apparent, I would like to have 0 equalling white and 255 black.  If I  
remember correctly, grey scale is linear function, which means that I  
should be able to simply subtract the received values by 255.

Is that correct?

Thank you very much in advance!

Sebastian
Reply | Threaded
Open this post in threaded view
|

Re: Converting 8-bit Grey Scale

Robert Baer
At the risk of exposing my ignorance, I would submit it depends what you
mean by subtract.

Basically, you are dealing with a computer byte and what you want to do is
complement the bits.  If by subtraction you mean byte subtraction, your
method works.  If by subtraction you mean 2 byte or 4 byte subtraction, you
will arrive at something that may or may not represent what you want if you
simply subtract 255.

There are basically two commands related (but different) to what you may
want to do that are available from the ImageJ menu.  Compare analyze
histogram after each to understand the difference.  The effect on image
appearance is similar in the two cases.

For example, open the bridge.gif sample.  Note that it is 8-bit greyscale.
Do Analyze | Histogram and note that the mean is 114, and the mode is 85.

Now do, Edit | Invert   The visual image complements.  Analyze histogram
produces a mean of 141 and a mode of 170.  Note that 114+141=255 and
85+170=255.  Thus, 255-x gives the appropriate mean or mode of the inverted
histogram.  The image is inverted and the histogram is inverted.

Open a fresh copy of the sample bridge.gif.   Do Image | Lookup tables |
invert LUT  Again the visual image swaps blackness and whitness.  Now,
analyze | histogram produces a mean of 114 and a mode of 85,  the same
histogram values as produced by the origninal image.  The image appearance
is inverted but the histogram is unchanged.

Finally, open Bridge.gif sample and do Edit | Invert followed by Image |
Lookup tables | Invert LUT.  The image appears as it originally did.
Analyze histogram shows a mean of 141 and a mode of 170.  The image is
unchanged but the histogram is inverted.  If I understand you, this is
exactly the effect you wish to acheive.

This can be done by macro with:
run("Bridge (174K)");
run("Invert");
run("Invert LUT");

Hope this helps,
Rob



----- Original Message -----
From: "Sebastian Baumbach" <[hidden email]>
To: <[hidden email]>
Sent: Friday, August 28, 2009 12:53 PM
Subject: Converting 8-bit Grey Scale


> Hey All,
>
> I have analyzed pressure sensitive film using imageJ.  I am using  several
> processing steps and finally receive a 8-bit grey scale  image.  I am
> analyzing the pressure using the grey values which I  receive through the
> histogram tool embedded in ImageJ.  0 equals black  and 2 white 55.
>
> To make the correlation between grey values and pressure more  apparent, I
> would like to have 0 equalling white and 255 black.  If I  remember
> correctly, grey scale is linear function, which means that I  should be
> able to simply subtract the received values by 255.
>
> Is that correct?
>
> Thank you very much in advance!
>
> Sebastian
>