I want to draw lines cross 2 images so that the start and end points of each line which belong to different images are connected. These 2 points are match points or features after the computation of image correlation.
To my knowledge, I can only draw 2 images in the same figure via subplot. But how to draw a line across those 2 images (subplots) so that related points are connected? I guess that if we can get the coordinate of each subplot we can draw such a line. But I don't know how to get the coordinate of each subplot and then how to get the size (width and height) of each plot. Could you please give me some advice on it? Thanks a lot in advance.
Mutang
You might create an axis that takes the entire surface of the figure, plot a line on it, and make it invisible.
figure(1); clf(1);
subplot(2,1,1);
plot(rand(1,10));
subplot(2,1,2);
plot(rand(1,10));
ax=axes('Position',[0 0 1 1],'Unit','normalize',...
'parent',1);
plot(ax,[0 1],[0 1],'k');
set(ax,'Xtick',[],'Ytick',[],'Visible','off');
% Bruno
Thanks a lot, Bruno. I have tried what you said. But first I don't understand why plot(ax,[0 1],[0 1],'k') draws an inclined line that connects the bottom left corner to the up right corner. Could you please tell me why? Thanks a lot.
Another question is still I don't know how to draw a line from one pixel in one image to the other pixel in another image. I think the main problem now is how to calculate the start and end points of each line through the coordinates of each image. I mean, although we have the start and end of the 2 matching pixels in 2 images respectively (local coordinates), we still can not draw a line connecting them since we don't know the position of each image in the plot.
In additon, I want to paste an image to demonstrate my target plot in this message. But I don't know how to attach such an image in this message. Could you please tell me how to realize it? Thanks a lot.
Xianyong
Because I draw a line that connect the point (0,0) to (1,1) of axes "ax". That lower-left and upper-right corners, because ax takes the whole figure. You can set your own unit by using axis command.
>
> Another question is still I don't know how to draw a line from one pixel in one image to the other pixel in another image. I think the main problem now is how to calculate the start and end points of each line through the coordinates of each image. I mean, although we have the start and end of the 2 matching pixels in 2 images respectively (local coordinates), we still can not draw a line connecting them since we don't know the position of each image in the plot.
You need to convert the coordinates from the subplot axe that you need to pass in the plot command on the invisible axe. For each subplot "subax", use commands such as:
set(subax,'Unit','normalize') then
get(subax,'Position',...)
get(subax,'Xlim')
get(subax,'Ylim')
and work down the arithmetic from there.
For more details, see "Properties Controlling Axes Size" in help file.
Bruno
Dear Bruno, I see. Thanks a lot for your kind help. I will check more details from the help file you suggested.
Mutang