Masking an RGB Image with Binary Mask

﹥>﹥吖頭↗ 提交于 2019-12-02 08:18:12

You are misusing imfilter() there. Imfilter is used for linear filter operations, not for masking or thresholding. Better do this:

z = image;          % image() is also a function. 
                    % Overwriting this name should be avoided

% Request user polygon for ROI
bw = roipoly(z);

% Create 3 channel mask
mask_three_chan = repmat(bw, [1, 1, 3]);

% Apply Mask
z(~mask_three_chan) = 0;

% Display
imshow(z);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!