Out a scale on the image?

3 views (last 30 days)
Irfan Tahir
Irfan Tahir on 4 Jul 2017
Commented: Irfan Tahir on 4 Jul 2017
Hi, I need to put the scale the length scale im mm along the image? how can i do that. My image is 0.101 mm/pixel
% code
a=imread('C00001.tif');
imshow(a);
How can i do that? An example is the one attached

Accepted Answer

Image Analyst
Image Analyst on 4 Jul 2017
Try using line() and text() to put them into the overlay:
grayImage = imread('cameraman.tif');
imshow(grayImage);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
mmPerPixel = 0.101;
% Find out how many pixels 10 mm is
pixelsPerCm = 10 / mmPerPixel;
% Draw a line
x1 = 10; % Starting column.
x2 = x1 + pixelsPerCm;
y = round(0.9 * rows);
line([x1, x2], [y, y], 'Color', 'r', 'LineWidth', 3);
text(x1, y-20, '1 cm', 'Color', 'r', 'FontSize', 20);

More Answers (0)

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!