1

With MATLAB, it is easy to show an image, and then plot a point on the image. For example,

figure; imshow(image);
hold on; plot(x,y,'r*');

This can usually work if the point is within the image. When the coordinate (x,y) is not in the range of the image, however, it will not work. For example x=-100,y=-200, in this case, when we use the above codes, the point is not visible anymore. How can I make sure that the point is also visible? Thanks.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
feelfree
  • 11,175
  • 20
  • 96
  • 167

1 Answers1

1

The problem is that imshow freezes the axis scale. You need to change the 'XLimMode' and 'YLimMode' properties of the axis to 'Auto' so that it auto-scales.

im = randn(300,300);
imshow(im)
hold on
set(gca, 'XLimMode', 'Auto', 'YLimMode', 'Auto')
plot(350,400,'r*')

enter image description here

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147