Posted by
Michael Schmid on
Jan 05, 2010; 3:01pm
URL: http://imagej.273.s1.nabble.com/Reading-pixel-value-tp3689806p3689807.html
Hi Muqueet,
here is a short description:
> float getPixelValue(int x, int y)
for FloatProcessors: pixel value
for ColorProcessors: brightness (0-255)
for 8&16 bit: calibrated value if calibration, uncalibrated value
(0-255, 0-65535) otherwise.
> int getPixel(int x, int y)
for 8&16-bit: uncalibrated pixel value
for ColorProcessors: an int holding the r, g, b values in the
three lowest bytes
for FloatProcessors: you have to convert this into a float number
by Float.intBitsToFloat()
> Object getPixels()
an array of all pixels. byte[], short[], int[] and float[] for
Byte, Short, Color and Floatprocessors, respectively.
So, if you want to read pixel values and have your plugin work for
all types of ImageProcessor, use float getPixelValue(int x, int y).
If you are writing a PlugInFilter, the easiest is to specify the
CONVERT_TO_FLOAT flag. Then your filter will be always called with a
FloatProcessor (uncalibrated), and after filtering, the data will be
converted back. For ColorProcessors, this is done three times (once
for each color). In this case, one would usually access the pixels
array:
float[] pixels = (float[])ip.getPixels();
float value = pixels(x+y*width);
Michael
________________________________________________________________
On 5 Jan 2010, at 11:15, Muqeet Khan wrote:
> Hi!
>
> Which is the right way of reading pixel data from a dicom image. If
> one
> looks at the ImageProcessor
> http://[
http://rsb.info.nih.gov/ij/developer/api/ij/process/
> ImageProcessor.html
> ] ImageProcessor
>
> float getPixelValue(int x, int y)
> Object getPixels()
> int getPixel(int x, int y)
>
> Thanks
>