alternative of ismember function

I need to replace ismember in this program with equivalent function(not inbuild),any ideas?
x=randi([1, M-h],1,1); % M,N size of image and h,w dimension of rectangle
y=randi([1 ,N-w],1,1);
if ismember(Vf,I(x:x+h,y:y+w))
fail_count=fail_count+1;
I'm generating non overlapping rectangles,here ismember is checking wthether point x,y lies inside a rectangle or not.
I(x:x+h,y:y+w)) is rectangle.

2 Comments

That code is checking to see if the value of Vf is the same as any of the pixel values stored in I(x:x+h, y:y+w) . That would not check to see whether x, y lies inside a rectangle.
In the case where you are using I to record the rectangles that have already been drawn, then if you use true to indicate a location already filled, then
if any(any(I(x:x+h, y:y+w)))
%it overlaps with something that is already filled
end
I need to replace ismember
Why? How can we know what's acceptable if you don't tell us why ismember is not acceptable.

Sign in to comment.

Answers (0)

Asked:

on 7 Sep 2019

Commented:

on 7 Sep 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!