How to plot a point 300 pixels to the right in an image?
Show older comments
So I've a variable created called 'J' which is situated at a certain point in the image, how do I plot it 300 pixels to the right of the point its situated? it seems to be moving along the wrong axis when Im trying to move it rightwards.
Answers (1)
Image Analyst
on 23 Feb 2015
What is J? I'll assume it's a 1 by 2 array with the x (column) coordinate, followed by the y (row) coordinate. Then to plot 300 columns to the right, do
plot(J(1)+300, J(2), 'r*', 'MarkerSize', 20, 'LineWidth', 2);
Make sure you're not making the very common mistake of mixing up x,y with row, column - that's almost certainly what you're doing. Remember images take indexes of (row, column) which is (y, x) while plot() takes (x,y) which is (column, row). Make sure you get it straight - like I said, this is a very common error.
7 Comments
Sean
on 23 Feb 2015
Image Analyst
on 23 Feb 2015
A screenshot would do wonders. I still think you've swapped x and y and that's why it's moving in the wrong direction. Use x,y or row,column. If you mix them, you've got to be very careful.
Sean
on 23 Feb 2015
Sean
on 23 Feb 2015
Image Analyst
on 23 Feb 2015
So if the blue line is moved 300 pixels to the right, how would you tell? It's practically horizontal. I guess the left endpoint of the line would not be at the left edge anymore, but that's about the only way I could tell that it moved.
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
