Code covered by the BSD License

### Highlights fromMinimaMaxima3D

5.0

5.0 | 1 rating Rate this file 14 Downloads (last 30 days) File Size: 2.94 MB File ID: #17997

# MinimaMaxima3D

13 Dec 2007 (Updated 14 Dec 2007)

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

File Information
Description

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.

Use:

[Maxima,MaxPos,Minima,MinPos]=MinimaMaxima3D(Input,[Robust],[LookInBoundaries],[numbermax],[numbermin])

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

Acknowledgements

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
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
 Please login to add a comment or rating.
Comments and Ratings (1)
11 Apr 2011

Contact us