% With this program you can: % load an single image or a frame from a video, measure (semi-manually) the % distance between two points (in pixels), and determine the scale (pix to % mm conversion). % by R. Zenit, Brown University % last updated September 8, 2020 %clear all %close all % video file %path=''; %filename= 'scale.MOV' % image file filename=['outsforscale.png']; %filename=['profforscale.bmp']; % type the physical distance in INCHES Length= .3; %NOZZLE LENGTH %For image file photo=imread(filename); %For video %Frame to be uploaded, if video is used % Firstframe=400; % mov3 = VideoReader(filename); % numberOfFrames = mov3.NumberOfFrames; % vidHeight = mov3.Height; % vidWidth = mov3.Width; % photo= read(mov3,Firstframe); figure(1) clf imshow(photo,'InitialMagnification', 200); axis image; hold on title('Click on first point') pos1=ginput(1) x1=pos1(1); y1=pos1(2); plot(x1,y1,'m +') title('Click on second point') pos2=ginput(1) x2=pos2(1); y2=pos2(2); plot(x2,y2,'m +') k=line([x2 x1],[y2,y1]); set(k,'linestyle','--','color','r') distance_pix=sqrt((x1-x2)^2+(y1-y2)^2); % Calculate conversion factor % in pix/mm scale=distance_pix/Length title(['Conversion factor ', num2str(scale), ' pix/mm'])