MATLAB Answers

0

Get pixel of data coordinate

Asked by Jonathan Mole on 29 Jul 2019
Latest activity Commented on by Jonathan Mole on 3 Aug 2019
I want to get the pixel value of a selected data point on a figure (.m matlab figure).
For example in figure; plot(2,2,'*')
what is the pixel associated with the (2,2) data point?
I do not wish to use imtool since I generate many figures inside the same code and I wish to put a '\rightarrow' at the (2,2) data point.
And, the axis changes for these figures so the (2,2) data point also changes its pixel values in my code.
Cheers

  0 Comments

Sign in to comment.

Tags

Products


Release

R2018a

2 Answers

Answer by Image Analyst
on 30 Jul 2019

You can use getpixel() to get the pixel value, or use indexing, like pixelValue = yourImage(y, x, :).
To put an arrow into the overlay, use annotation().

  2 Comments

Hi,
is getpixel a matlab function? And for the part pixelValue = yourImage(y, x, :), this does not seem to work. Maybe because the figure is a .m format?
Image Analyst
on 30 Jul 2019
Maybe it's imgetpixel(). Try that. But actually, I just use indexing all the time.
A figure cannot be an m-file. It can be generated by an m-file, but cannot be an m-file itself. You either
  1. used image(), imagesc(), pcolor(), or imshow() to display a digital image, OR
  2. you plotted something with plot(), scatter(), surf(), bar(), etc.
So, which was it?

Sign in to comment.


Answer by Jonathan Mole on 31 Jul 2019

imgetpixel does not work... neither does pixelvalue.
I used plot as for the example described above plot(2,2,'*')

  2 Comments

I think that the correct answer to this would be: if you do not know the answer, it would be rather preferable not to comment.

Sign in to comment.