Login  Register

Re: Best path to take

Posted by Rasband, Wayne (NIH/NIMH) [E] on Oct 13, 2013; 8:18pm
URL: http://imagej.273.s1.nabble.com/Best-path-to-take-tp5005126p5005154.html

On Oct 10, 2013, at 4:28 PM, Robert Lockwood wrote:

>>> Why not just save the images in TIFF format? Why invent
>>> another file format?
>
> When I saw that I could save the files as TIFF I gave it a try but that
> destroys the original data. What's is apparently saved is the image data,
> that is, it's reduced to  BufferedImage.  That was a disappointing
> exercise.
>
> I know that it is possible for a TIFF file to have the original data in it
> but AFAIK Fiji doesn't support writing this Scientific data mode, alas.

ImageJ can save 16-bit unsigned scientific data in TIFF format, including metadata (properties). Here is an example:

   int w=256, h=256;
   short[] data = new short[w*h];
   for (int i=0; i<w*h; i++)
      data[i] = (short)i;
   ImageProcessor ip = new ShortProcessor(w, h, data, null);
   ImagePlus imp = new ImagePlus("temp", ip);
   String properties = "key1: value1\nkey2: value2";
   imp.setProperty("Info", properties);
   IJ.saveAsTiff(imp, IJ.getDirectory("home")+"test.tiff");

To save using lossless compression, replace the IJ.saveAsTiff() call with:

   IJ.saveAs(imp, "zip", IJ.getDirectory("home")+"test.tiff");

Open and display the file using File>Open and display the metadata by typing "i" (Image>Show Info).

A plugin can open the TIFF file and retrieve the short data using:

   ImagePlus imp = IJ.openImage(path);
   ImageProcessor ip = imp.getProcessor();
   short[] data = (short[])ip.getPixels();

It can retrieve the metadata using:

   ImagePlus imp = IJ.openImage();
   String properties = imp.getProperty("Info");

-wayne


> ---------- Forwarded message ----------
> From: Rasband, Wayne (NIH/NIMH) [E] <[hidden email]>
> Date: Thu, Oct 10, 2013 at 1:08 PM
> Subject: Re: Best path to take
> To: Robert Lockwood <[hidden email]>
>
> Dear Robert,
>
> Why not just save the images in TIFF format? Why invent another file format?
>
> Best regards,
>
> -wayne
>
>
> On Oct 10, 2013, at 3:29 PM, Robert Lockwood wrote:
>
>> Johannes, thanks for your help with my initial attempt to write a plugin.
>>
>> Before I proceed I am asking you and others in the group for some advice.
>>
>> My situation is that we are developing a camera system for in house
>> infrared photography, primarily of wild fires.  At this point I need to be
>> able to provide a way for others to view our image data and thought that
>> Fiji would be a good solution.
>>
>> I've decided that our images will all have a metadata header and the first
>> 24 bytes would be identical in function.  Our image data is all (C-talk
>> here) unsigned shorts with the 12-14 bits of precision depending on the
>> camera and are monochrome.
>>
>> The size varies greatly among the cameras with a probable minimum of 512
>> lines by 640 pixels up to 11 megapixels.  The image data for most of the
>> cameras are very low contrast unless fire is in the image and consist of
>> raw DN values.
>>
>> The common part of the header, the minimum information for the image to be
>> displayed, is"  Offset-to-image-data, number-of-lines,
>> number-of-samples-per-line, pixel-size, and time-of-acquisition (Java date
>> time in ms).  The first four data are Java ints, and the time is a Java
>> long for a total of 24 bytes.
>>
>> I'd like to tell the few people who need to view the images to just
>> download and install Fiji on their LINUX, Macs, and Windows machines, and
>> then how to load and use the plugin/macro I supply.  The object is for the
>> user to use Fiji to browse and display  our  files (possible extension
>> .rawimage) and not need to enter any image metadata as they may not know
>> those data.  Once the image is in Fiji it can be manipulated, saved-as,
>> etc.  In essence it should work analogous to importing a raw image without
>> needing to input metadata by hand.
>>
>> TIA for any insight, pointers, etc.
>>
>> Nate
>>
>> --
>> When I was 12 I thought I would live forever.
>> So far, so good.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
>
> --
> When I was 12 I thought I would live forever.
> So far, so good.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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