开发者

Get x and y coordinates into variables in macro ImageJ

开发者 https://www.devze.com 2023-02-12 05:22 出处:网络
I want to be able to place a point in an image using the point selection tool, then read the x and y coordinates to variable in a macro.

I want to be able to place a point in an image using the point selection tool, then read the x and y coordinates to variable in a macro.

I've tried getSelectionCoordinates but that isn't working. I don't want to display the coordinates in a log or results win开发者_运维百科dow.

Any help would be much appreciated.


getSelectionCoordinates works fine for me, e.g.:

s = selectionType();

if( s == -1 ) {
    exit("There was no selection.");
} else if( s != 10 ) {
    exit("The selection wasn't a point selection.");
} else {
    getSelectionCoordinates(xPoints,yPoints);
    x = xPoints[0];
    y = yPoints[0];
    showMessage("Got coordinates ("+x+","+y+")");
}

(A common misunderstanding is that getSelectionCoordinates doesn't return a value conventionally - you have to give it the names of variables that it'll set.)

0

精彩评论

暂无评论...
验证码 换一张
取 消