-
Notifications
You must be signed in to change notification settings - Fork 1
/
zz_dip.m
93 lines (91 loc) · 4.09 KB
/
zz_dip.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%ZZ Creates an image with Z coordinates
% ZZ(M,N,P,...) or ZZ([M,N,P,...]) returns an image of size
% M-by-N-by-P-by-... with the value of the Z-coordinate of each
% pixel as the pixel values.
%
% ZZ(A) is the same as ZZ(SIZE(A)).
%
% ZZ(...,ORIGIN) allows specifying where the origin is:
% 'left' the pixel to the left of the true center
% 'right' the pixel to the right of the true center (default)
% 'true' the true center, between pixels if required
% 'corner' the pixel on the upper left corner (indexed at (0,0))
% Note that the first three are identical if the size is odd.
%
% ZZ(..,'freq') uses frequency domain coordinates, range=(-0.5,0.5)
% (not in combination with ORIGIN).
% ZZ(..,'radfreq') uses frequency domain coordinates, range=(-pi,pi)
% (not in combination with ORIGIN).
% (C) Copyright 1999-2001 Pattern Recognition Group
% All rights reserved Faculty of Applied Physics
% Delft University of Technology
% Lorentzweg 1
% 2628 CJ Delft
% The Netherlands
%
% Cris Luengo, November 2000.
% 20 April 2001: Improvements. Fixed 1D version. Using CREATERAMP.
% 26 April 2001: Added to menu.
% Added 'frequency' option.
% 8 August 2001: Copied parameter parsing from NEWIM. Changed help accordingly.
% 15 November 2002: added/improved createramp options.
function out = zz(varargin)
origin = '';
sz = [256,256];
N = nargin;
if N > 0
if ischar(varargin{N})
origin = varargin{N};
if strcmp(origin,'DIP_GetParamList') % Add to menu
options = struct('name',{'left','right','true','corner','freq','radfreq',...
'mleft','mright','mtrue','mcorner','mfreq','mradfrq'},...
'description',{'left of true center','right of true center','true center',...
'top-left corner','frequency domain','frequency domain in radians',...
'left of true center, math mode','right of true center, math mode',...
'true center, math mode','top-left corner, math mode',...
'frequency domain, math mode','frequency domain in radians, math mode'});
out = struct('menu','Generation',...
'display','Z-coordinate',...
'inparams',struct('name', {'sz', 'origin'},...
'description',{'Input image','Location of origin'},...
'type', {'image', 'option'},...
'dim_check', {0, 0},...
'range_check',{[], options},...
'required', {0, 0},...
'default', {'a', 'right'}...
),...
'outparams',struct('name',{'out'},...
'description',{'Output image'},...
'type',{'image'}...
)...
);
return
end
N = N-1;
end
if N > 1
for ii=1:N
if ~isnumeric(varargin{ii}) | prod(size(varargin{ii})) ~= 1 | mod(varargin{ii},1)
error('Input arguments must be scalar integers.')
end
end
sz = cat(2,varargin{1:N});
elseif N == 1
sz = varargin{1};
if isa(sz,'dip_image')
sz = size(sz);
elseif isa(sz,'dip_image_array')
error('Input image is an image array.')
elseif ~isnumeric(sz) | isempty(sz)
error('Size vector must be a row vector with integer elements.')
elseif sum(size(sz)>1)>1
% Treat sz as an image
sz = size(dip_image(sz));
end
end
end
try
out = createramp(sz,3,origin);
catch
error(firsterr)
end