【发布时间】:2013-12-08 17:51:03
【问题描述】:
我通过impoly('Closed', true) 在图片上创建了一个封闭区域,最后在 Matlab 命令行中标记了遮罩BW = createMask(h) 的区域之后。
图中掩码标记点前的初始命令
imshow('contour.png');
h = impoly('Closed',true);
在这里,我在下面使用了 nkjt 的 答案。 函数conditionalRemoval(image, area)
要过滤的图片然后,我跑
image = imread('contour.png');
areaLazyRemoval = BW;
image = conditional_removal(image, areaLazyRemoval);
我现在有mask 和图片。 我应该对它们应用 conditional_removal 功能。
你现在如何使用这个掩码并将函数应用到它的标记区域?
我的函数conditional_removal的伪代码是
function [ image ] = conditional_removal( image, areaLazyRemoval )
% dim image 794 x 1001 x 3 uint
% dim areaLazyRemoval 794 x 1001 logical
image(:,:,1) .* areaLazyRemoval; % TODO wrong operator here!
% all pixels marked by logical ones in areaLazyRemoval should get lazyRemoval applied
% else greedyRemoval so zero
%
end
%%%%%%%%%%%%%%%%%%%%%%%
% lazy removal function
% so remove by 50% chance the thing
function pixel = lazyRemoval(pixel)
if randn > 0
pixel = 0;
end
% TODO how to apply pixel-wise removal to the logical matrix and image?
如何通过逻辑矩阵蒙版对图像进行逐像素移除?
【问题讨论】:
-
您必须将数据传递给
createfigure才能绘制它。createfigure的代码是什么? -
@DanielR 就是这个:dl.dropboxusercontent.com/u/62073194/createfigure.m
-
我提供了该问题的 SSCCE 示例,以便您可以重现该问题。现在有一个问题的最小图片,如何创建它的代码,如何使用它的代码以及错误。
-
我根据nkjt的回答更新了正文。