Code covered by the BSD License  

Highlights from

5.0 | 2 ratings Rate this file 33 Downloads (last 30 days) File Size: 2.94 MB File ID: #17997 Version: 1.0
image thumbnail




13 Dec 2007 (Updated )

Find the minima and maxima in a 3D Cartesian data space

| Watch this File

File Information

V 1.0 Dec 13, 07
Author Sam Pichardo.
This function finds the local minima and maxima in a 3D Cartesian data.
It's assumed that the data is uniformly distributed.
The minima and maxima are calculated using a multi-directional derivation.
where Input is the 3D data and Robust (optional and with a default value
of 1) indicates if the multi-directional derivation should include the
diagonal derivations.
Input has to have a size larger or equal than [3 x 3 x 3]
If Robust=1, the total number of derivations taken into account are 26: 6
for all surrounding elements colliding each of the faces of the unit cube;
10 for all the surrounding elements in diagonal.
If Robust =0, then only the 6 elements of the colliding faces are considered
The function returns in Maxima and MaxPos, respectively,
the values (numbermax) and subindexes (numbermax x 3) of local maxima
and position in Input. Maxima (and the subindexes) are sorted in
descending order.
Similar situation for Minima and MinimaPos witn a numbermin elements but
with the execption of being sorted in ascending order.
IMPORTANT: if numbermin or numbermax are not specified, ALL the minima
or maxima will be returned. This can be a useless for highly
oscillating data
LookInBoundaries (default value of 0) specifies if a search of the minima/maxima should be
done in the boundaries of the matrix. This situation depends on the
the desire application. When it is not activated, the algorithm WILL NOT
FIND ANY MINIMA/MAXIMA on the 6 layers of the boundaries.
When it is activated, the finding minima and maxima on the boundaries is done by
replicating the extra layer as the layer 2 (or layer N-1, depending of the boundary)
By example (and using a 2D matrix for simplicity reasons):
For the matrix
[ 4 1 3 7
  5 7 8 8
  9 9 9 9
  5 6 7 9]
the calculation of the partial derivate following the -x direction will be done by substrascting
[ 5 7 8 8
  4 1 3 7
  5 7 8 8
  9 9 9 9]
to the input. And so on for the other dimensions.
Like this, the value "1" at the coordinate (1,2) will be detected as a
minima. Same situation for the value "5" at the coordinate (4,1)

This function was inspired by extreme2.m of C.A. Vargas, even if I followed a somewhat different approach for the spatial derivation.

The biggest advantage is that the function is fast (at least for my 500k elements matrices) and, I hope, the code is quite simple.

Enjoy and let me know your thoughts


Extrema.M, Extrema2.M inspired this file.

MATLAB release MATLAB 7.2 (R2006a)
Other requirements Tested under Centos 5 x64 It should work in previous versions of Matlab
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Feb 2015 Xindi Li

The examples are great, thank you

11 Apr 2011 xiang fiona  

Contact us