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