-
Notifications
You must be signed in to change notification settings - Fork 3
/
pic2prof.m
48 lines (42 loc) · 1.4 KB
/
pic2prof.m
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
47
48
function varargout=pic2prof(mn1,mn2,A,fname,dname)
% [pxy,A,mn1,mn2]=PIC2PROF(mn1,mn2,A,fname,dname)
%
% Reads a picture, outputs values a straight-line profile
%
% INPUT:
%
% mn1 Row (first dimension, y if your will) and
% column (second dimension, x if you will) number
% of the first point of the profile
% mn2 Row and column number of the second point of the profile
% A The image file - if you don't have, leave empty, provide:
% fname The picture filename [defaulted]
% dname The directory name [defaulted]
%
% OUTPUT:
%
% pxy The profile of image values, as obtained from IMPROFILE
% A The image loaded
% mn1,mn2 The values used
%
% EXAMPLE:
%
% tic; [~,A]=pic2prof ; toc
% tic; pic2prof([],[],A); toc
%
% Last modified by fjsimons-at-alum.mit.edu, 03/21/2019
% Specify defaults
defval('dname','/u/fjsimons/STUDENTS/AlexCavoli/')
defval('fname','Around180_greyscale.jpg')
% exist(fullfile(dname,fname))
% ls(fullfile(dname,fname))
% Read the image, if it doesn't exist yet
defval('A',imread(fullfile(dname,fname)));
% Specify more defaults
defval('mn1',[randi(size(A,1)) randi(size(A,2))])
defval('mn2',[randi(size(A,1)) randi(size(A,2))])
% Extract the profile
pxy=improfile(A,[mn1(1) ; mn2(1)],[mn1(2) mn2(2)]);
% Provide any and all outputs
varns={pxy,A,mn1,mn2};
varargout=varns(1:nargout);