Saving Raw 32-bit images with imageJ API

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

Saving Raw 32-bit images with imageJ API

Wise, Bowden (GE, Research)
Hi,
I want to use imageJ to scale some images to decimate them. The input
images are 32-bit real, 2048x2048 images, with little endian. I can read
the images by setting the FileInfo parameters appropriately. However, I
cannot figure out how to save the image back out as 32-bit real,
512x512, little endian.
I tried using FileInfo with appropriate settings and using the FileSaver
but it does not appear to be saving correctly. How do others save their
images as raw?
If I save the same image out as a PNG file, the data is indeed scaled
properly.
Am I missing something?
Thanks!
Bowden
Reply | Threaded
Open this post in threaded view
|

Re: Saving Raw 32-bit images with imageJ API

Michael Schmid
Hi Bowden,

if you want to reduce the size, you can use the Averaging Reducer  
plugin that comes with the installation (under Plugins>Demos)
For saving as raw, the FileInfo won't be of much help.
In the Edit>Options>I/O Options, there is a checkbox "Save tiff & raw  
in Intel byte order" that switches between little endian and big endian.

You can translate most commands to the API by recording with the  
Macro Recorder and then converting "run" to "IJ.run".

Michael
________________________________________________________________

On 6 Jul 2010, at 17:02, Wise, Bowden (GE, Research) wrote:

> Hi,
> I want to use imageJ to scale some images to decimate them. The input
> images are 32-bit real, 2048x2048 images, with little endian. I can  
> read
> the images by setting the FileInfo parameters appropriately.  
> However, I
> cannot figure out how to save the image back out as 32-bit real,
> 512x512, little endian.
> I tried using FileInfo with appropriate settings and using the  
> FileSaver
> but it does not appear to be saving correctly. How do others save  
> their
> images as raw?
> If I save the same image out as a PNG file, the data is indeed scaled
> properly.
> Am I missing something?
> Thanks!
> Bowden
Reply | Threaded
Open this post in threaded view
|

Re: Saving Raw 32-bit images with imageJ API

Wise, Bowden (GE, Research)
In reply to this post by Wise, Bowden (GE, Research)
Michael,

Thanks for your reply. I am using the Java API for imageJ which is why I referred to the classes FileInfo and FileSaver. I am looking to use imageJ to manipulate images offline (no user interface). I can load, resize the image using the Java API but just can't save it back out. So are you saying there is no way to save a raw image using the Java API?

Thanks!
Bowden
Reply | Threaded
Open this post in threaded view
|

Re: Saving Raw 32-bit images with imageJ API

Unruh, Jay-2
Bowden,

The great thing about raw files is that you don't need the ImageJ API--just write the data stream directly to file.  If you look at the ImageJ source code for the ImageWriter class and method writeFloatImage(OutputStream out,float[] pixels), you will see how it is done for little and big endian.  Here is the link to the source page I am talking about:

http://rsb.info.nih.gov/ij/developer/source/ij/io/ImageWriter.java.html

Jay Unruh
Stowers Institute for Medical Research

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Bowden Wise
Sent: Tuesday, July 06, 2010 5:07 PM
To: [hidden email]
Subject: Re: Saving Raw 32-bit images with imageJ API

Michael,

Thanks for your reply. I am using the Java API for imageJ which is why I referred to the classes FileInfo and FileSaver. I am looking to use imageJ to manipulate images offline (no user interface). I can load, resize the image using the Java API but just can't save it back out. So are you saying there is no way to save a raw image using the Java API?

Thanks!
Bowden
Reply | Threaded
Open this post in threaded view
|

Re: Saving Raw 32-bit images with imageJ API

Wise, Bowden (GE, Research)
In reply to this post by Wise, Bowden (GE, Research)
Jay,

Thanks for the pointer to ImageWriter. I was able to save out my raw image just fine.

Bowden
Reply | Threaded
Open this post in threaded view
|

Re: Saving Raw 32-bit images with imageJ API

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Wise, Bowden (GE, Research)
On Jul 6, 2010, at 11:02 AM, Wise, Bowden (GE, Research) wrote:

> Hi,
> I want to use imageJ to scale some images to decimate them. The input
> images are 32-bit real, 2048x2048 images, with little endian. I can read
> the images by setting the FileInfo parameters appropriately. However, I
> cannot figure out how to save the image back out as 32-bit real,
> 512x512, little endian.
> I tried using FileInfo with appropriate settings and using the FileSaver
> but it does not appear to be saving correctly. How do others save their
> images as raw?
> If I save the same image out as a PNG file, the data is indeed scaled
> properly.
> Am I missing something?
> Thanks!
> Bowden

In Edit>Options>Input/Output, enable "Save TIFF and raw in Intel byte order", then save the images using File>Save As>Raw. The images will be saved as raw in their current format (8-bit, 16-bit unsigned, 32-bit float or RGB).

With JavaScript or a plugin, use

 imp = IJ.getImage();
 Prefs.intelByteOrder = true;
 IJ.saveAs(imp, "Raw Data", path);

-wayne