-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathLocalMax.m
35 lines (32 loc) · 1.1 KB
/
LocalMax.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
function [maxima] = LocalMax(image)
%
% LOCALMAX Finds local maxima of image
%
% [maxima,i,j] = LocalMax(image)
%
% outputs array maxima of zeros and ones with ones
% at maxima position (Extended to 9 points by JYB)
%
%support routine for 'trackdemo.m' (help trackdemo)
%
%
%Contributors to this code include: Jean-Yves Bouguet, Hailin Jin, Paolo Favaro.
%Last updated 5/5/2003.
%
%DISTRIBUTED FREE FOR NON-COMMERCIAL USE
%Copyright (c) MASKS, 2003
[m,n] = size(image);
center_cols = [1:n];
center_rows = [1:m];
left = [2:n n];
right = [1 1:n-1];
top = [2:m m];
bot = [1 1:m-1];
maxima = ( ( (image(center_rows,center_cols) > image(center_rows,left)) & ...
(image(center_rows,center_cols) > image(center_rows,right)) & ...
(image(center_rows,center_cols) > image(top,center_cols)) & ...
(image(center_rows,center_cols) > image(bot,center_cols)) & ...
(image(center_rows,center_cols) > image(top,left)) & ...
(image(center_rows,center_cols) > image(top,right)) & ...
(image(center_rows,center_cols) > image(bot,left)) & ...
(image(center_rows,center_cols) > image(bot,right))));