ip.getPixel returns 'index' not 'value'

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

ip.getPixel returns 'index' not 'value'

Tony Shepherd
I'm using a greyscale image. When I place the mouse pointer over a
homogenous part of the image, the ImageJ toolbar tells me the following:

x=99, y=130, index=8, value=192,192,192.

In my program I use int greyvalue = ip.getPixelValue(x,y);

where x and y are defined inside the same algorithm.

For the same homogenous region as above (eg x=99, y=130) I expect to get
greyvalue = 192.
I get greyvalue = 8.

I suspect that I'm using a LUT without knowing it (or wanting it).

Is there a function that returns 'value' instead of 'index' (eg the value in
the red channel, since this is the same as the value in the green and blue
channels)
Reply | Threaded
Open this post in threaded view
|

AW: ip.getPixel returns 'index' not 'value'

Lucas, Falk /BDF HAM
Hi,

it looks like your Image is not a grayscale image scince you get three numbers for the value, there should be only one.

Falk

-----Ursprüngliche Nachricht-----
Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von Tony Shepherd
Gesendet: Montag, 4. September 2006 19:41
An: [hidden email]
Betreff: ip.getPixel returns 'index' not 'value'

I'm using a greyscale image. When I place the mouse pointer over a homogenous part of the image, the ImageJ toolbar tells me the following:

x=99, y=130, index=8, value=192,192,192.

In my program I use int greyvalue = ip.getPixelValue(x,y);

where x and y are defined inside the same algorithm.

For the same homogenous region as above (eg x=99, y=130) I expect to get greyvalue = 192.
I get greyvalue = 8.

I suspect that I'm using a LUT without knowing it (or wanting it).

Is there a function that returns 'value' instead of 'index' (eg the value in the red channel, since this is the same as the value in the green and blue
channels)

_____________________  Confidentiality  _____________________

This electronic transmission is strictly confidential and intended
solely for the addressee.  It may contain information which is covered
by legal, professional or other privilege.  If you are not the intended
addressee, you must not disclose, copy or take any action in reliance
of this transmission.  If you have received this transmission in error,
please notify us and delete the received data as soon as possible.

This footnote also confirms that this email message has been swept
for the presence of computer viruses.
_______________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: AW: ip.getPixel returns 'index' not 'value'

Tony Shepherd
In reply to this post by Tony Shepherd
Well that's true, I just meant greyscale in the sense that: red = green =
blue. The image must have been converted or saved in the wrong format at
some point.

The point is, the ImageJ toolbar can dynamically tell me what the greylevel
(or red and green and blue) values are but the ip.getPixel or
ip.getPixelValue methods can not make this information available to my
algorithm...
Reply | Threaded
Open this post in threaded view
|

Re: ip.getPixel returns 'index' not 'value'

Wayne Rasband
In reply to this post by Tony Shepherd
Convert the image to one with the standard grayscale LUT by selecting
Image>Type>8-bit. This should work even if "8-bit" is already checked
in the Type menu.

-wayne

On Sep 4, 2006, at 1:41 PM, Tony Shepherd wrote:

> I'm using a greyscale image. When I place the mouse pointer over a
> homogenous part of the image, the ImageJ toolbar tells me the
> following:
>
> x=99, y=130, index=8, value=192,192,192.
>
> In my program I use int greyvalue = ip.getPixelValue(x,y);
>
> where x and y are defined inside the same algorithm.
>
> For the same homogenous region as above (eg x=99, y=130) I expect to
> get
> greyvalue = 192.
> I get greyvalue = 8.
>
> I suspect that I'm using a LUT without knowing it (or wanting it).
>
> Is there a function that returns 'value' instead of 'index' (eg the
> value in
> the red channel, since this is the same as the value in the green and
> blue
> channels)
>
Reply | Threaded
Open this post in threaded view
|

Re: ip.getPixel returns 'index' not 'value'

Harry Parker
In reply to this post by Tony Shepherd
Hi Tony,

Your results indicate you are looking at an 8-bit Color, a.k.a. "pseudocolor" image. The pixel value IS 8, and the associated LUT value for 8 is (R,G,B) = (192, 192, 192). You can confirm this by selecting the menu Image->Type, and notice what type is checked.

Try this:
(1) Convert the image to "RGB Color" format. (Menu: Image->Type->RGB Color). This will convert all the 8 valued pixels into actual R,G & B values of 192, for example. The image will also be 3 times larger.
(2) Optionally, to save memory space and simplify the measurements, then convert the image to grey scale (Menu: Image->Type->8-bit).

NOW you have a real grayscale image, and the getPixelValue function works as you expect.
 
--  
Harry Parker  
Senior Systems Engineer  
Dialog Imaging Systems, Inc.

----- Original Message ----
From: Tony Shepherd <[hidden email]>
To: [hidden email]
Sent: Monday, September 4, 2006 1:41:08 PM
Subject: ip.getPixel returns 'index' not 'value'

I'm using a greyscale image. When I place the mouse pointer over a
homogenous part of the image, the ImageJ toolbar tells me the following:

x=99, y=130, index=8, value=192,192,192.

In my program I use int greyvalue = ip.getPixelValue(x,y);

where x and y are defined inside the same algorithm.

For the same homogenous region as above (eg x=99, y=130) I expect to get
greyvalue = 192.
I get greyvalue = 8.

I suspect that I'm using a LUT without knowing it (or wanting it).

Is there a function that returns 'value' instead of 'index' (eg the value in
the red channel, since this is the same as the value in the green and blue
channels)
Reply | Threaded
Open this post in threaded view
|

Re: ip.getPixel returns 'index' not 'value'

Tony Shepherd
In reply to this post by Tony Shepherd
I see what you mean. Thanks.
Is there any way I can change the image type during runtime, i.e. call a
method at the start of my code to ensure I'm working with the data that I
want to work with, regardless of whether the user has changed the image typr
from the IJ menu ?
Reply | Threaded
Open this post in threaded view
|

Re: ip.getPixel returns 'index' not 'value'

Harry Parker
Hi Tony,

You asked:
-----------
Is there any way I can change the image type during runtime, i.e. call a
method at the start of my code to ensure I'm working with the data that I
want to work with, regardless of whether the user has changed the image typr
from the IJ menu ?


------------

Have you seen the plugins tutorial on the ImageJ web site? See section 4.8.

-- Harry