0

I was looking into the region of interest tutorial set here and there are a few things that escape my understanding.

The example given to create a binary mask for setting the ROI is

img = imread('pout.tif');
h_im = imshow(img);
e = imellipse(gca,[55 10 120 120]);
BW = createMask(e,h_im);

I understand that an ellipse imellipse is used to create the ROI object. So following its own page here I read more about it but no where on that page does it explain what gca is? all it says is that it is an hparent and specifies the HG parent of the ellipse. I do not understand this can some one please elaborate. Can I use something else in place of gca? and what is gca?

Also in this line the imshow function is assigned to h_im and then further used. When I did this with my installation with a sample image I got this value h_im = 1.740099 so h_im is a double value.

This is further used here BW = createMask(e,h_im); I understand that these are the parameters meaning:

BW = createMask(h,h_im) returns a mask the same size as the image h_im with 1s inside the ROI object h and 0s outside. This syntax is required when the axes that contain the ROI hold more than one image.

so is 1.740099 the size of the image? In which units is this measured?

Also when I wrote the last line in my Matlab I got the following error:

>> BW = createMask(h,h_im);
??? Invalid or deleted object.

Error in ==> imroi>imroi.parseInputsForCreateMask at 78
            h_ax = ancestor(obj.h_group,'axes');

Error in ==> imroi>imroi.createMask at 264
            [obj,h_im] = parseInputsForCreateMask(varargin{:});

Why am I getting this error?

Thank you

4

1 回答 1

2

gca是一个返回当前坐标区句柄的函数。同样,h_im 是 imshow 创建的图像对象的句柄。您可以在此处阅读有关使用 Mathworks 句柄的更多信息。

检查句柄时看到的数字与图像的属性(大小等)无关 - 该值可能与对象的类型有关,但基本上它们是 Matlab 用来跟踪打开的图形对象的标识符。因此,当您调用 imellipse 时,您将一个句柄传递给将出现椭圆的轴,并在e.

e = imellipse(gca,[55 10 120 120]);

或者,gca您可以使用另一个指向不同轴的句柄来代替。例如,如果您有:

a1 = subplot(1,2,1), h1 = imshow(img1)
a2 = subplot(1,2,2), h2 = imshow(img2)

然后,您可以根据要在哪个图像中创建 roi 来使用a1a2代替 gca。

如果您关闭包含图像和椭圆的图形,这些句柄将被删除 - 这就是您收到错误“无效或已删除对象”的原因。一旦您使用createMask并返回了您想要的面具,就可以关闭该图。

于 2013-09-01T22:49:40.867 回答