MATLAB: How to put a ruler in an image

image processing

I have an image with a resolution of (556 * 292) pixel. The height of image is 108 mm. how to put a ruler on image so that the expected output file will look like image shown (image is manualy edited). first one is input image and second one is expected output image.
Spray 1.png
spray 2.jpg

Best Answer

What command did you use to show the image?
Try imshow(), and set the xdata or ydata properties to meet what you want.