Login  Register

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

Posted by Michael Schmid on Nov 12, 2013; 7:24pm
URL: http://imagej.273.s1.nabble.com/Getting-row-or-column-data-for-32-bit-image-in-Java-tp5005541p5005544.html

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