Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I create a closed region on a picture by impoly('Closed', true) and lastly after marking the area for the mask BW = createMask(h) in Matlab commandline. Initial commands before marking points for the mask in the figure

imshow('contour.png');
h = impoly('Closed',true);

Here, I used nkjt's answer below. The picture to be filtered by the function conditionalRemoval(image, area)

enter image description here

Then, I run

image = imread('contour.png');
areaLazyRemoval = BW; 
image = conditional_removal(image, areaLazyRemoval);

I now have the mask and the picture. I should apply the function conditional_removal to them.

How can you use this mask now and apply the function to it in the its marked region?

My function conditional_removal's pseudocode is

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?

How can you apply the pixel-wise removal to the image by the logical matrix, mask?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
367 views
Welcome To Ask or Share your Answers For Others

1 Answer

By this:

impoly > Generate Data > function createfigure1

Do you mean after calling impoly, you go into the figure window and select "Generate Code"? Which will create a function createfigure - but this has nothing to do with impoly.

There are a couple of ways you can extract the ROI.
After choosing the area with impoly, before closing the figure:

BW = createMask(h);

Or you can extract the position with getPosition and then use roipoly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...