Posted by
Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Determining-origin-of-Z-coordinates-tp5020239p5020289.html
> 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