Reputation: 12460
I have one set of points (x1,y1) from Image 1, I1, and another set of points (x2,y2) from Image 2, I2.
I would like to first adjoin two images by newI = [I1 I2] %twice as wide
Then, on new image, I would like to draw points from (x1,y1) to (x2,y2).
The problem is set of points are based on its original image and not adjoined image.
so, how do i convert points from (x1,y1) and (x2, y2) to be the points on the new image?
and then, how do i draw lines between these points. I m not quite sure how to use matlab plot
ie (x11,y11) -> (x21,y21) all the way till (x1i,y1i) -> (x2i, y2i) ith point
Upvotes: 0
Views: 222
Reputation: 350
If I understand correctly (x1, y1)
are indices of points on image I1
. Matlab represents image pixels in same order. So a point in the image x1
from left and y1
from top is located at index (x1, y1)
.
Now when you join images by [I1 I2]
, it is same as positioning the second image to the right of first image. This translates the second image to left by width of first image, which is number of columns of first image and can be accessed by size(I1,2)
.
To account for this shift, you need to add appropriate shift for second image.
(x2, y2) --> (( x2 + size(I1,2) ), y2 )
Note we do not need to need to shift y2
as the images are same height.
Also if you have multiple points which need to be plotted it is advisable to save the image dimensions in separate variable.
I am guessing you are using the notation (x11, y11)
and (x21, y21)
to refer to points (x1, y1)
and (x2, y2)
on the adjoined image.
To draw a line from (x1, y1)
to (x2, y2)
, assuming a1 = [x1, y1]
and a2 = [x2, y2]
, then you can say plot([a1(1), a2(1)], [a1(2), a2(2)])
. This can be improved but I need to know how you store the points.
Upvotes: 1