0
作爲後續行動,以我的問題here:createMask和函數調用語法
- 是什麼
createMask
實際上呢?我去了MathWorks here的描述,但不是很清楚。 - 如果您在上面引用的問題的答案中看到:
img2(roi.createMask) = 1;
,roi.createMask
部分讓我想起函數調用,那我們真的在這裏做什麼?調用createMask
函數?
謝謝。
作爲後續行動,以我的問題here:createMask和函數調用語法
createMask
實際上呢?我去了MathWorks here的描述,但不是很清楚。img2(roi.createMask) = 1;
,roi.createMask
部分讓我想起函數調用,那我們真的在這裏做什麼?調用createMask
函數?謝謝。
在代碼
img = im2double(imread('cameraman.tif'));
imshow(img);
roi = imfreehand(gca);
img2 = img;
img2(roi.createMask) = 1;
imshow(img2);
roi
是手柄由imfreehand
產生的對象。通過對象(使用句柄)可用的方法(〜函數)之一是createMask
,可以使用.
運算符訪問。該方法生成一個類型爲logical
的陣列,其大小與圖像的像素尺寸相同。邏輯陣列中的值爲1
或0
,其值爲1
,分配給與使用imfreehand
操作選擇的區域對應的區域中的條目。操作img2(roi.createMask) =1;
使用邏輯陣列中值爲1
的位置將圖像編入圖像img2
(它挑選img2
中的元素),並將這些元素值指定爲1
。
我的回答有幫助嗎?你需要額外的澄清嗎? –