필터 지우기
필터 지우기

Using roipoly on plots

조회 수: 6 (최근 30일)
Aaron Smith
Aaron Smith 2017년 7월 7일
댓글: Adam 2017년 7월 11일
Is the roipoly command only usable on image files? I need to select a region of interest (possibly several) on a contourf plot of data. After trying to use the roipoly command on one of my plots it generates an error saying an image must be present in the current figure. If this is the case and there is no way to use roipoly on plots, is there an alternate command for selecting region of interest? I had previously used data cursor but roipoly then seemed like a preferable option.
  댓글 수: 8
Aaron Smith
Aaron Smith 2017년 7월 7일
I used imrect to draw a rectangle (h) on the contourf plot of my matrix. I then used createMask(h) to create a mask and got the error:
Error using imroi/parseInputsForCreateMask (line 91)
createMask expects a current figure containing an image.
Error in imroi/createMask (line 258)
[obj,h_im] = parseInputsForCreateMask(varargin{:});
Adam
Adam 2017년 7월 11일
You can by-pass createMask, which is basically just a wrapper function and go straight to the function that it calls,
doc poly2mask
by using the points defined my imrect or impoly. This function needs to be given an image size (to create the mask of that size), but does not need an image itself e.g.
hPoly = impoly( hAxes );
...
polyPos = getPosition( hPoly );
x = polyPos(:,1); y = polyPos(:,2);
imSize = [100 200];
binaryMask = poly2mask( x, y, imSize(1), imSize(2) );

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by