figure, imshow, saveas and getpts

조회 수: 4 (최근 30일)
Douglas Brenner
Douglas Brenner 2016년 10월 13일
댓글: Image Analyst 2018년 4월 21일
I save an image using saveas. Then I open it and display it using imshow in figure 1. When I use getpts to get pixel coordinates, the coordinates I get are that of figure 1 not that of the image. I.e, If I click on the axis of the image, I don't get (0,0), I get the coordinates of the image origin in figure 1. How do I get the image coordinates?

답변 (2개)

Image Analyst
Image Analyst 2016년 10월 13일
Save images with imwrite(). Recall them with imread(). Display them with imshow(). Get pixel values with impixelinfo:
hp = impixelinfo();
This will let you mouse around and display the (x,y) and gray level in a status label on your figure. If you need the user to click on a point, then use ginput():
[x, y] = ginput();
  댓글 수: 5
Douglas Brenner
Douglas Brenner 2016년 10월 13일
Got it. You have to write and read it as uint8
Image Analyst
Image Analyst 2016년 10월 13일
Yes, for most standard image formats. Or you could use uint16. If you want to keep as floating point instead of integers, use save() to save as a .mat file, then use load() to recall it.

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


Ramesh Bala
Ramesh Bala 2018년 4월 20일

but in this case [x,y] = getpts

x =

118.5645
242.4355

y =

199.6316
197.2105

its giving both x1y1 and x2 y2...how to get only x1x2

  댓글 수: 1
Image Analyst
Image Analyst 2018년 4월 21일
You already have that in your x variable.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by