Getting row or column data for 32-bit image in Java

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

Getting row or column data for 32-bit image in Java

Neil Fazel
Is there a way to get row or column data for a 32-bit floating point image? The methods getRow() and getColumn() are inherited by FloatProcessor from ImageProcessor but they return integer data not float. I'm looking for something like

getRow(int x,int y,float[] data,int length)
getColumn(int x,int y,float[] data,int length)

but this doesn't seem to be supported. Is getFloatArray(), which returns 2D data, the only way to get 32-bit pixel data without losing accuracy?

Thanks,
Neil

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

Re: Getting row or column data for 32-bit image in Java

Michael Schmid
Hi Neil,

the most direct way to access float data of a FloatProcessor is ip.getPixels();
It gives a 1D float[] array.  You can then use System.arraycopy to extract a row:

  float[] pixels = (float[])ip.getPixels();
  System.arraycopy(pixels, y+width, rowArray, 0, width);

For extracting a column, you have to step through the pixels array in increments of 'width'

  for (int y=0,p=x; y<height; y++,p+=width)
    colArray[y] = pixels[p];

Michael
________________________________________________________________
On Nov 12, 2013, at 19:46, Neil Fazel wrote:

> Is there a way to get row or column data for a 32-bit floating point image? The methods getRow() and getColumn() are inherited by FloatProcessor from ImageProcessor but they return integer data not float. I'm looking for something like
>
> getRow(int x,int y,float[] data,int length)
> getColumn(int x,int y,float[] data,int length)
>
> but this doesn't seem to be supported. Is getFloatArray(), which returns 2D data, the only way to get 32-bit pixel data without losing accuracy?
>
> Thanks,
> Neil

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