Extract region/outline coordinates using ginput
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I have to boundary line over a coin. My question is how can I get only the region coordinates which is marked by two ginput crosshairs.
Thanks in advance.
I = imread('coins.png');
imshow(I)
BW = im2bw(I);
imshow(BW)
dim = size(BW)
col = round(dim(2)/2)-90;
row = min(find(BW(:,col)))
boundary = bwtraceboundary(BW,[row, col],'N');
imshow(I)
hold on;
plot(boundary(:,2),boundary(:,1),'b','LineWidth',2);
[x, y] = ginput(2);
plot(x, y,'r+','MarkerSize', 11);
댓글 수: 0
답변 (1개)
Image Analyst
2017년 10월 11일
I'm not sure what you want to do. You can get the boundaries of all binary blobs using bwboundaries(), not bwtraceboundary():
boundaries = bwboundaries(BW);
Beyond that, I have no idea what you're trying to do by asking the user to click two points somewhere in the image.
댓글 수: 6
Image Analyst
2017년 10월 12일
Did you see the example in the documentation? Probably not. So look at it. You can get the x and y coordinates like this:
[cx,cy,c] = improfile(I)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!