alternative of ismember function
7 views (last 30 days)
Show older comments
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
Walter Roberson
on 7 Sep 2019
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
Guillaume
on 7 Sep 2019
I need to replace ismember
Why? How can we know what's acceptable if you don't tell us why ismember is not acceptable.
Answers (0)
See Also
Categories
Find more on Categorical Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!