Determining origin of Z coordinates

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

Determining origin of Z coordinates

Stein Rørvik
ImageJ allows you to define an origin elsewhere than the upper left corner of the image,
allowing measurements in physical coordinates where applicable.

This works well for both XY and Z coordinates.
For example, we can define the origin of the "T1 Head" sample stack as the centre of the middle slice:

run("T1 Head (2.4M, 16-bits)");
run("Properties...", "origin=128,128,64");

What I need to do is to determine the location of this origin later, from a macro.

For XY, this is easy. I just convert scaled position 0,0 to pixel coordinates:

x = 0;
y = 0;
toUnscaled(x, y);
print("x: " + x);
print("y: " + y);

But how can I get the pixel Z coordinate of the origin?

toUnscaled(x, y, z) does not work.

The easy fix to this would be to allow this third Z parameter in the toScaled and toUnscaled macro commands, for consistency.

Perhaps even better, a getOrigin(x,y,z) command?


Stein


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

Re: Determining origin of Z coordinates

Wayne Rasband-2
> On Mar 9, 2018, at 3:04 AM, Stein Rørvik <[hidden email]> wrote:
>
> ImageJ allows you to define an origin elsewhere than the upper left corner of the image,
> allowing measurements in physical coordinates where applicable.
>
> This works well for both XY and Z coordinates.
> For example, we can define the origin of the "T1 Head" sample stack as the centre of the middle slice:
>
> run("T1 Head (2.4M, 16-bits)");
> run("Properties...", "origin=128,128,64");
>
> What I need to do is to determine the location of this origin later, from a macro.
>
> For XY, this is easy. I just convert scaled position 0,0 to pixel coordinates:
>
> x = 0;
> y = 0;
> toUnscaled(x, y);
> print("x: " + x);
> print("y: " + y);
>
> But how can I get the pixel Z coordinate of the origin?
>
> toUnscaled(x, y, z) does not work.

Upgrade to the latest daily build (1.52a4) and toUnscaled(x, y, z) will work. Both toScaled() and toUnscaled() now support a third z argument.  Here is an updated version of your example:

  run("T1 Head (2.4M, 16-bits)");
  run("Properties...", "origin=128,128,64");
  x=0; y=0; z=0;
  toUnscaled(x, y, z);
  print("x origin: " + x);
  print("y origin: " + y);
  print("z origin: " + z);

-wayne


> The easy fix to this would be to allow this third Z parameter in the toScaled and toUnscaled macro commands, for consistency.
>
> Perhaps even better, a getOrigin(x,y,z) command?
>
>
> Stein

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

Re: Determining origin of Z coordinates

Stein Rørvik
Thanks, works great!

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne Rasband
Sent: 14. mars 2018 21:21
To: [hidden email]
Subject: Re: Determining origin of Z coordinates

...

Upgrade to the latest daily build (1.52a4) and toUnscaled(x, y, z) will work. Both toScaled() and toUnscaled() now support a third z argument.  Here is an updated version of your example:

  run("T1 Head (2.4M, 16-bits)");
  run("Properties...", "origin=128,128,64");
  x=0; y=0; z=0;
  toUnscaled(x, y, z);
  print("x origin: " + x);
  print("y origin: " + y);
  print("z origin: " + z);

-wayne


> The easy fix to this would be to allow this third Z parameter in the toScaled and toUnscaled macro commands, for consistency.
>
> Perhaps even better, a getOrigin(x,y,z) command?
>
>
> Stein

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

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