alternative of ismember function

1 回表示 (過去 30 日間)
Mayank Nautiyal
Mayank Nautiyal 2019 年 9 月 7 日
コメント済み: Guillaume 2019 年 9 月 7 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 9 月 7 日
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 2019 年 9 月 7 日
I need to replace ismember
Why? How can we know what's acceptable if you don't tell us why ismember is not acceptable.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by