Login  Register

Spatial and density calibration from TIFF files to ImageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Spatial and density calibration from TIFF files to ImageJ

Davide Guarisco
3 posts
Hello,
        I have tried to find this information elsewhere but was not successful, so I am posting here.

I am writing a Python script that converts a proprietary image format into a TIFF file, which I subsequently intend to open in ImageJ. I want to transfer the information regarding both the scaling (spatial calibration) and density (Z-values) via the TIFF file.

I tried to determine how ImageJ saves this information by looking at the files generated before and after setting a scale and adding a calibration. For the Z scale, it seems that ImageJ just adds the following to the Image Description (e.g., in the case of a linear calibration):

cf=0 c0=0.0 c1=0.3326 vunit=nm

For the spatial calibration, via searching this list, I was able to find that ImageJ uses the x_resolution, y_resolution TIFF tags. This works, except that the unit is not set. How can I communicate the unit of the spatial resolution? Notice that a standard TIFF tag is unit_resolution. However, this only supports three values (1=none, 2=inch, 3=cm).

To save the TIFF files from Python there are many possibilities. I am leaning towards tifffile.py for now. If anybody has an opinion on this, please let me know as well.

Thank you in advance.

Davide

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

signature.asc (890 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Spatial and density calibration from TIFF files to ImageJ

Olivier Burri
149 posts
Hi Davide,

Looking at a tiff image saved by ImageJ, it's the same thing as for the zunit:
ImageJ adds a unit=micron or whichever yours is to the ImageDescription tag

Hope this helps.

Best

Oli

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Davide Guarisco
> Sent: Monday, October 19, 2015 6:03
> To: [hidden email]
> Subject: Spatial and density calibration from TIFF files to ImageJ
>
> Hello,
> I have tried to find this information elsewhere but was not
> successful, so I am posting here.
>
> I am writing a Python script that converts a proprietary image format into a
> TIFF file, which I subsequently intend to open in ImageJ. I want to transfer
> the information regarding both the scaling (spatial calibration) and density (Z-
> values) via the TIFF file.
>
> I tried to determine how ImageJ saves this information by looking at the files
> generated before and after setting a scale and adding a calibration. For the Z
> scale, it seems that ImageJ just adds the following to the Image Description
> (e.g., in the case of a linear calibration):
>
> cf=0 c0=0.0 c1=0.3326 vunit=nm
>
> For the spatial calibration, via searching this list, I was able to find that ImageJ
> uses the x_resolution, y_resolution TIFF tags. This works, except that the
> unit is not set. How can I communicate the unit of the spatial resolution?
> Notice that a standard TIFF tag is unit_resolution. However, this only
> supports three values (1=none, 2=inch, 3=cm).
>
> To save the TIFF files from Python there are many possibilities. I am leaning
> towards tifffile.py for now. If anybody has an opinion on this, please let me
> know as well.
>
> Thank you in advance.
>
> Davide
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: Spatial and density calibration from TIFF files to ImageJ

Davide Guarisco
3 posts
In reply to this post by Davide Guarisco
Oli, thank you for your answer.

Unfortunately, this does not seem to work. Here's the code I am using:

from PIL import Image
stepsize =  params['scanX']/params['nrows']
opts2 = 'ImageJ=1.50b unit=nm cf=0 c0=0 c1=0.33 vunit=nm'
ar = Image.fromarray(img_data)
ar.save('AFM3.tiff',description=opts2,x_resolution=1/stepsize, y_resolution=1/stepsize)

The Image Description received by ImageJ, as shown using the Debug mode, is:

Image Description: ImageJ=1.50b unit=nm cf=0 c0=0 c1=0.33 vunit=nm

The image has the correct X and Y scaling, but the unit is still "pixel".
The Z values calibration does not take effect.

It seems I am missing something obvious, but what?

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