循环 ROI 不是从输入中提取的
Circular ROI is not being drawn from input
出于某种原因,以下代码仅显示 roi 为 10,10、高度和宽度为 100,100 的蒙版图像。这些是初始值。似乎即使在 getPosition 函数之后图像也不会更新。谁能解释一下这个问题?
`I = imread('/Users/imageuser/Documents/PT300.tif');
h = imshow(I);
% define circular roi by square bounding box
x = 10;
y = 10;
d1 = 100;
d2 = 100;
e = imellipse(gca, [x y d1 d2]);
% roi can be interactively moved/adjusted
% do not close figure window before createMask is called
%%% these lines are only needed if you move or resize the roi
pos = getPosition(e);
x = pos(1);
y = pos(2);
d1 = pos(3);
d2 = pos(4);
%%%
BW = createMask(e,h);
pause;
imshow(BW);`
您需要输入这些行(注意我颠倒了它们的顺序):
pause;
BW = createMask(e,h);
在调用getPosition
之前,否则不会更新新位置。
完整代码:
clear
clc
close all
I = imread('coins.png');
h = imshow(I);
% define circular roi by square bounding box
x = 10;
y = 10;
d1 = 100;
d2 = 100;
e = imellipse(gca, [x y d1 d2]);
pause;
BW = createMask(e,h);
% roi can be interactively moved/adjusted
% do not close figure window before createMask is called
%%% these lines are only needed if you move or resize the roi
pos = getPosition(e)
x = pos(1);
y = pos(2);
d1 = pos(3);
d2 = pos(4);
%%%
figure
imshow(BW);
拖动 ROI 后的示例输出:
耶!
注意:正如 juicestain 所提到的,当用户完成创建 GUI 时,您可以使用 wait
来等待用户双击,而不是使用 pause
来停止程序的执行单击 ROI 对象,而不是像使用 pause
命令那样必须按键。
因此,您可以将对 pause
的调用替换为对 wait(e)
的调用。
出于某种原因,以下代码仅显示 roi 为 10,10、高度和宽度为 100,100 的蒙版图像。这些是初始值。似乎即使在 getPosition 函数之后图像也不会更新。谁能解释一下这个问题?
`I = imread('/Users/imageuser/Documents/PT300.tif');
h = imshow(I);
% define circular roi by square bounding box
x = 10;
y = 10;
d1 = 100;
d2 = 100;
e = imellipse(gca, [x y d1 d2]);
% roi can be interactively moved/adjusted
% do not close figure window before createMask is called
%%% these lines are only needed if you move or resize the roi
pos = getPosition(e);
x = pos(1);
y = pos(2);
d1 = pos(3);
d2 = pos(4);
%%%
BW = createMask(e,h);
pause;
imshow(BW);`
您需要输入这些行(注意我颠倒了它们的顺序):
pause;
BW = createMask(e,h);
在调用getPosition
之前,否则不会更新新位置。
完整代码:
clear
clc
close all
I = imread('coins.png');
h = imshow(I);
% define circular roi by square bounding box
x = 10;
y = 10;
d1 = 100;
d2 = 100;
e = imellipse(gca, [x y d1 d2]);
pause;
BW = createMask(e,h);
% roi can be interactively moved/adjusted
% do not close figure window before createMask is called
%%% these lines are only needed if you move or resize the roi
pos = getPosition(e)
x = pos(1);
y = pos(2);
d1 = pos(3);
d2 = pos(4);
%%%
figure
imshow(BW);
拖动 ROI 后的示例输出:
耶!
注意:正如 juicestain 所提到的,当用户完成创建 GUI 时,您可以使用 wait
来等待用户双击,而不是使用 pause
来停止程序的执行单击 ROI 对象,而不是像使用 pause
命令那样必须按键。
因此,您可以将对 pause
的调用替换为对 wait(e)
的调用。