forked from nubs01/TrodesExtractionGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetPixelToCM.m
More file actions
executable file
·46 lines (37 loc) · 987 Bytes
/
getPixelToCM.m
File metadata and controls
executable file
·46 lines (37 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function conversion = getPixelToCM(framenum)
if nargin==0
framenum=1;
end
[FileName,PathName] = uigetfile({'*.m4v'; '*.mp4';'*.h264'}, 'Select a Video file');
filename = ([PathName FileName]);
v = VideoReader(filename);
video = read(v,framenum);
repeat = 0;
while repeat == 0;
h=figure();
imagesc(video);
hold on
msgbox('Click for start and end')
pause(2)
[x,y]=ginput(2);
line('XData',x,'YData',y, 'color', 'g')
hold off
pixel_length = sqrt((x(1)-x(2))^2+(y(1)-y(2))^2);
% Construct a questdlg with three options
choice = questdlg('Repeat the line drawing?');
% Handle response
switch choice
case 'Yes'
repeat = 0;
close(h)
case 'No'
repeat = 1;
msgbox('YAY!')
case 'Cancel'
repeat = 1;
msgbox('Oops')
end
end
cmLen = input('What is the length of the line in cm? ');
conversion = pixel_length/cmLen;
close(h)