How to have a selected code in matlab?

조회 수: 2 (최근 30일)
saba sabu
saba sabu 2017년 5월 15일
댓글: Walter Roberson 2017년 5월 22일
Hi dears, my question topic is not clear because it is a little hard to explain what i want. I wrote a code in Matlab to analyze an image to find a point. Code found 10 points for me, but i need a selective point. it means that i want to select true point by click on image with 10 points and after selecting true point, i will do this for all images that i have to analyze. how can i do this? somebody advise me to use GUI, is it possible?How? Thank you friends...

채택된 답변

Cam Salzberger
Cam Salzberger 2017년 5월 15일
Hello Saba,
The easiest way would probably to bring up the image with "imshow", and allow for you to select any one point on the image with "ginput(1)". Then the code could take the output of "ginput" and determine which of the ten possible points are closest to the one selected. Once that is found, the code can save that as the "true point", and then move on to the next image.
-Cam
  댓글 수: 4
Cam Salzberger
Cam Salzberger 2017년 5월 15일
편집: Cam Salzberger 2017년 5월 15일
I prefer not to edit other people's code, since they are the ones who know their code the best. Here's a simple example with some built-in data though:
% Example image
I = imread('peppers.png');
% Example points
[nRows, nCols, ~] = size(I);
xPts = randi(nCols,10,1);
yPts = randi(nRows,10,1);
% Show image and example points
figure
imshow(I)
hold on
plot(xPts,yPts,'or')
% Allow for selecting one point
[x, y] = ginput(1);
% Find closest match
dist = sqrt((xPts-x).^2+(yPts-y).^2);
[~, idxPt] = min(dist);
% Show point on image
plot(xPts(idxPt),yPts(idxPt),'+g')
Not sure what you want to do once you've found the "true point", so I just plotted it.
Walter Roberson
Walter Roberson 2017년 5월 22일
saba sabu comments to Image Analyst:
Thanks Dear "Image Analyst".

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by