alternative of ismember function

1 vue (au cours des 30 derniers jours)
Mayank Nautiyal
Mayank Nautiyal le 7 Sep 2019
Commenté : Guillaume le 7 Sep 2019
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 commentaires
Walter Roberson
Walter Roberson le 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
Guillaume le 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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by