How to plot a point 300 pixels to the right in an image?

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.

Réponses (1)

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 commentaires

Sean
Sean le 23 Fév 2015
J is a mean value for the line sfit! sfit is a line of best fit for the segment s which was plotted using my 'get_white_edges' function. I'm looking to find out the mid point of the 1 by 2 array that is sfit. the line will always be 1024 columns wide as when there are white edges detected on the images it always travels the whole way across the image. However the row at which it begins can vary. Therefore when I run my function I'm not quite sure how to find out automatically which row the best fit is situated. since the line is always 1024 long I thought I could move J 512 pixels to the right as then it will be the mid point of 1024, i.e. 1024 divided by 2. Ignore why I said 300 it was just as an example.
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
Sean le 23 Fév 2015
Sean
Sean le 23 Fév 2015
Hi please see above, sfit would be an example of the blue line, for example the beginning of the white region.
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.
Sean
Sean le 23 Fév 2015
Modifié(e) : Sean le 23 Fév 2015
I've used the command
J=mean(fit);
to create the midpoint for the blue line, however when I go to plot it, it is situated at the very beginning of the blue line, therefore I was trying to move 'J' to the very centre of the picture by adding 512 to it. Is there a better way to create the midpoint for the blue line (sfit)? since I don't know its x coorrdinate ?
Sean
Sean le 23 Fév 2015
Modifié(e) : Sean le 23 Fév 2015
For example, See J plotted as the blue star. I'm looking to get the centre of the line or midpoint. Thanks also for the help!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Question posée :

le 23 Fév 2015

Modifié(e) :

le 23 Fév 2015

Community Treasure Hunt

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

Start Hunting!

Translated by