MATLAB Answers

How to get pixel coordinates that make up a curve in a graph?

20 views (last 30 days)
MatlabFan on 10 Mar 2013
I need help finding the coordinates of the pixels that make up the curve in the image which I have included the link to at the bottom of this message. I do not want to get the pixel coordinates of the axis or numbers on the axis; only of the plotted curve. I know that I should have a code that I wrote and go from there to ask for assistance. The thing is that I have never worked on image processing before, and I just need to get over this step to complete the project I'm working on.
Please if you have some time and can help me on at least getting started, I will be very appreciative. I have tried googling my issue, but it didn't help me build my own code to do the job I want. I guess it's because, as I said before, I have never worked on image processing prior to today really... and come on, don't ask me to go and read about it; just help me if you can.
I am familiar with Matlab.


Sign in to comment.

Accepted Answer

Matt J
Matt J on 10 Mar 2013
If you read it in as an RGB image, it should just be a matter of searching for pixels that have a sufficiently large blue component.
locations = (rgb(:,:,3)>=threshold);
You would have to pick the threshold, obviously, but if you do imshow(A) and zoom in on the curve and probe it using the data tip, you should be able to get a good idea of its blue levels.


Show 1 older comment
Matt J
Matt J on 10 Mar 2013
As you have it now, the numbers in t are linear indices, i.e., the positions of the pixels as you raster scan through the image along columns. If you want the pixels in i,j matrix coordinates, you would do instead
[i,j]= find(r==0 & g==0 & b==255);
You could also convert t to (i,j) coordinates by doing
[i,j]=ind2sub(size(r), t);
Image Analyst
Image Analyst on 10 Mar 2013
The image goes way outside the axes. How did you determine the row number of the x axis, and the column number of the y axis? I know how I'd do it but just wondered how you did it, or if you did it, because otherwise your coordinates will be relative to the outside of the image, not relative to the axes.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!