Login  Register

Re: Pixel spacing broken on Save

Posted by Michael Schmid on Mar 23, 2015; 1:50pm
URL: http://imagej.273.s1.nabble.com/Pixel-spacing-broken-on-Save-tp5012113p5012114.html

Hi Michael,

as I understand it, ImageJ uses the standard TIFF tags for pixel width and pixel height. They don't accept negative values (and they also limit the pixel size to roughly between 1e-9 and 1e6; astrophysicists, beware ;-)

In y direction, there is a Calibration.invertY flag, which you can set in a Java plugin if you have negative pixel height (the +y direction going up). There is no equivalent in x direction, but it seems that you need it in y only.

On the macro level, I am not aware that one could access that flag. It seems that Set Measurements>Invert Y coordinates does not set the Calibration.invertY.

On the long term, it might make sense to modify io.TiffEncoder.writeScale such that it always uses positive numbers and sets the the Calibration.invertY flag.
Then the question is how to handle consistently the pixel aspect ratio in Set Scale, the pixel height in Image>Properties, and the macro commands getPixelSize, getVoxelSize and setVoxelSize.

Michael
________________________________________________________________
On Mar 23, 2015, at 13:24, Doube, Michael wrote:

> Hi,
>
> I've written a new plugin, Ellipsoid Factor (http://bonej.org/ef), that produces a modified Flinn plot as output. Its x,y axes have a scale of 0-1, with the origin in the lower left corner. That means the y pixel spacing is negative to invert the positive direction to 'up' on the screen. This works fine when displaying the image for the first time: the (x,y) coordinates of the cursor position are correctly reported in the status bar. But, when I save the image as a TIFF and reopen it, the y axis pixel spacing has been changed. Any suggestions to help with this would be gratefully received.
>
> Before saving:
> Width:  1 b/c (512)
> Height:  -1 a/b (512)
> X Resolution:  512 pixels per b/c
> Y Resolution:  -512 pixels per a/b
> Pixel size: 0.0020x-0.0020 (b/c x a/b)
> ID: -7
> Coordinate origin:  0,512
> Bits per pixel: 32 (float)
> Display range: 0 - 2032.1022
> No Threshold
> Uncalibrated
> Screen location: 515,906 (1200x1799)
> No Overlay
> No Selection
>
> After saving & opening.
> Width:  1 b/c (512)
> Height:  0.1353 a/b (512)
> X Resolution:  512 pixels per b/c
> Y Resolution:  3782.9673 pixels per a/b
> Pixel size: 0.0020x2.64E-4 (b/c x a/b)
> ID: -8
> Coordinate origin:  0,512
> Bits per pixel: 32 (float)
> Display range: 0 - 2032.1022
> No Threshold
> Uncalibrated
> Screen location: 358,551 (1200x1799)
> No Overlay
> No Selection
>
> ImageJ v1.49p
>
> Michael
>
>
> <http://www.rvc.ac.uk>
>
> This message, together with any attachments, is intended for the stated addressee(s) only and may contain privileged or confidential information. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Royal Veterinary College.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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