Find pixel coordinates of a line

I have used the find function to find the pixel coordinates of all the pixels in the three colored lines in the image. However, when I plot the pixel coordinates that I found, it looks like the lines have a different size.
The original image has a height of 2904 pixels and a width of 2890 pixels. So if you look at the plot, you can see that the position of the lines do not match up with those of the image. Why is this and how can I fix it?

 Accepted Answer

Image Analyst
Image Analyst on 30 May 2013
I don't see the problem - they look the same shapes to me. What are the lines of code that were used to plot the lines over the image, and what were the lines of code used to plot the lines in the line plot? You do know that the line plot has the origin of the displayed axis at (500, 400) don't you? You can set xlim() and ylim() if you want the line plot to have the origin at (1,1) like the image.

13 Comments

Looks like we're going to need your image if we are to reproduce this. Where did you upload it?
I uploaded the image on photobucket.com, but you can see the updated images on the original post.
The image in the original post has colored graphics (lines) burned into the image, plus toolbars, and other junk. That's no good. Please post the original image be itself, not a screenshot. All of that stuff will make it impossible to do the same thing as you because the lines obliterated the colors of the pixels that they're over.
Below is the original image that was given to me. All I need to do is pull the pixel coordinates of the colored lines off the image. I do not have the image without the three colored lines.
otherwise, you can go to the link below to download the image above:
I don't have time anymore tonight except to ask a quick question: Someone drew those colored lines, so why can't you get the coordinates from them? Instead of asking for the image with the graphics burned into it, can't you ask for the original image, and the coordinates in a separate text file? They should be able to do that for you.
The lines were drawn in photoshop and I am not sure if photoshop has the capability of giving a list of coordinates for all of the pixels. This is why I was trying to use matlab to get the coordinates for me. I could get the original image without the lines, but why would that be useful since we are only interested in the lines?
My code just finds all of the pixels with a certain RGB value and takes down its coordinates. However, as you can see in the images, the coordinates are slightly off and I do not know why.
Could I be making a mistake with trying to graph pixel position in a Cartesian coordinate system?
When you plot you have to reverse the y direction but it looks like you did that already because the curves are the same shape.
I am unable to download that image at full resolution from that site. Try it yourself, and then please tell me how. I don't see any download link and when I right click and save the image I get it at screen resolution which makes an image a lot smaller than what you say it is.
I can download it from the photobucket link that I posted and it is the same size that I had originally said. I just hit the download button that is under the media options menu. That is strange that it didn't work for you. How much smaller is it? Overall, you still run the code with that image, whatever the size is, to see what you got right?
OK - I didn't notice that small link. Maybe I might get to it today - no guarantees.
Tony D
Tony D on 3 Jun 2013
Edited: Tony D on 3 Jun 2013
I think that I figured it out, but I would need to remove the gray border on the figures so that the plot takes up the whole figure space. How can I do this?
Use set() to set the 'Position' property of the axes, something like (untested)
set(gca, 'Position', [.1, .2, .7, .5], 'Units', 'Normalized');

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!