MATLAB Answers


figure, imshow, saveas and getpts

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?

  0 件のコメント

サインイン to comment.

2 件の回答

Image Analyst
Answer by Image Analyst
on 13 Oct 2016

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 件のコメント

Your image may be floating point. Use []:
imshow(yourImage, []);
Got it. You have to write and read it as uint8
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.

サインイン to comment.

Answer by Kaleesh Bala on 20 Apr 2018

but in this case [x,y] = getpts

x =


y =


its giving both x1y1 and x2 to get only x1x2

  1 件のコメント

You already have that in your x variable.

サインイン to comment.

Translated by