필터 지우기
필터 지우기

Drawing polygon on axes GUI, Finding the area of a polygon

조회 수: 4 (최근 30일)
Adrian Lee
Adrian Lee 2020년 9월 3일
댓글: Cris LaPierre 2020년 9월 6일
According to this website, it is possible to draw a draggable polygon onto the image
Can i draw the polygon on the axes GUI?
And
is there a way to find the area of the polygon drawn by the code?

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 9월 4일
편집: Cris LaPierre 2020년 9월 4일
It's not clear if you are using app designer or guide. It should be simple enough to try. If you have trouble, share your code so we can help you.
As for the area, yes. Once you have finished drawing your polygon, use the polyshape and area functions. Here I've combined code from examples provided in the pages you and I have linked to.
I = imread('cameraman.tif');
imshow(I);
roi = images.roi.Polygon(gca,'Position',[115 30; 80 45; 80 80; 115 90; 145 65]);
p = polyshape(roi.Position)
area(p)
  댓글 수: 2
Adrian Lee
Adrian Lee 2020년 9월 5일
I am using guide
I am curious, roi = images.roi.Polygon(gca,'Position',[115 30; 80 45; 80 80; 115 90; 145 65]);
this code, can i instead of drawing the polygon on a image, draw it in the axes of guide?
Cris LaPierre
Cris LaPierre 2020년 9월 6일
Sure. Use the drawpolygon function. Instead of gca, use the handle to the axes in your gui (e.g. handles.axes1). You do need the Image Processing Toolbox.
roi = drawpolygon(handles.axes1);

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by