Pixel spacing broken on Save

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

Pixel spacing broken on Save

Michael Doube-4
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
Reply | Threaded
Open this post in threaded view
|

Re: Pixel spacing broken on Save

Michael Schmid
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
Reply | Threaded
Open this post in threaded view
|

Re: Pixel spacing broken on Save

Michael Doube-4
On 23/03/15 13:51, Michael Schmid wrote:
> 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).

Looks good, I'll have a go with this - excellent advice, as ever!

Michael
[RVC Logo - link to RVC Website]<http://www.rvc.ac.uk>    [Twitter icon - link to RVC (Official) Twitter] <http://twitter.com/RoyalVetCollege>     [Facebook icon - link to RVC (Official) Facebook] <http://www.facebook.com/theRVC>     [YouTube icon - link to RVC YouTube] <http://www.youtube.com/user/RoyalVetsLondon?feature=mhee>     [Pinterest icon - link to RVC Pinterest] <http://pinterest.com/royalvetcollege/>     [Instagram icon - link to RVC Instagram] <http://instagram.com/royalvetcollege>

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 (RVC). If you are not the intended recipient, please notify the sender and be advised that you have received this message in error and that any use, dissemination, forwarding, printing, or copying is strictly prohibited. Unless stated expressly in this email, this email does not create, form part of, or vary any contractual or unilateral obligation. Email communication cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, amended, lost, destroyed, incomplete or contain viruses. Therefore, we do not accept liability for any such matters or their consequences. Communication with us by email will be taken as acceptance of the risks inherent in doing so.

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

Re: Pixel spacing broken on Save

Michael Doube-4
In reply to this post by Michael Schmid
Hi Michael,

Just had a go with this. It's nicer code and makes more sense to invert the Y direction than have a negative size. However, the invertY flag appears not to be set in the TIFF during save, and so reopening the image results in a normal 'downwards' y axis. (Image is OK before saving though).

Michael

On 23/03/15 13:51, Michael Schmid wrote:

> 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