-
Notifications
You must be signed in to change notification settings - Fork 5
/
neiposkernel.m
40 lines (36 loc) · 1.03 KB
/
neiposkernel.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
%% NEIPOSKERNEL - Inscribed window indexing.
%
%% Description
% Create the kernel containing the index (and also subscript) positions of
% the grid pixels embedded within a square window of given radius within an
% image with given number of rows (I-dimension) relative to the center of
% this window.
%
%% Syntax
% ind = NEIPOSKERNEL(ws, X);
% [ind, ix, iy] = NEIPOSKERNEL(ws, X);
%
%% Inputs
% *|ws|* : radius of the square window.
%
% *|X|* : number of rows.
%
%% Outputs
% *|ind|* : index positions relative to the central pixel of the window of
% radius ws of the pixels contained in this window.
%
% *|ix, iy|* : subscript position relative to the central pixel (nothing else
% than the outputs of |NDGRID|).
%
%% See also
% Called:
% <matlab:webpub(whichpath('NDGRID')) |NDGRID|>.
%% Function implementation
function [ind, varargout] = neiposkernel(ws, X)
[ix, iy] = ndgrid(-ws:ws);
ind = ix + X*iy;
% ind = ind(:);
if nargout>1, varargout{1} = ix;
if nargout>2, varargout{2} = iy; end
end
end % end of neiposkernel