On Apr 22, 2015, at 11:11 AM, Miguel-Angel Manso-Callejo (UPM) <
[hidden email]> wrote:
>
> Dear all,
> I am interested on store a two dimensional array of float data in a tiff file.
>
> I have looking for libraries and i have found this.
> I am exciting to start writing a simple code in java that using this libraries store an image of float data pixels stored in a two dimensional array of float. I suppose that this is "simple”.
It is relatively simple. Here is an example that creates a 2D float array, creates an ImageProcessor from the array, creates an ImagePlus from the ImageProcessor, saves the ImagePlus in the user’s home directory as a TIFF file, opens the TIFF file and displays it.
-wayne
int n = 256;
float[][] array = new float[n][n];
for (int y=0; y<n; y++)
for (int x=0; x<n; x++)
array[x][y] = x;
ImageProcessor ip = new FloatProcessor(array);
ImagePlus img = new ImagePlus("Float Array", ip);
String dir = IJ.getDirectory("home");
IJ.saveAs(img, "tif", dir+"test.tif");
ImagePlus img2 = IJ.openImage(dir+"test.tif");
img2.show();
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html