MinimaMaxima3D

版本 1.0.0.0 (2.9 MB) 作者: Samuel Pichardo
Find the minima and maxima in a 3D Cartesian data space
2.9K 次下载
更新时间 2007/12/14

查看许可证

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

引用格式

Samuel Pichardo (2024). MinimaMaxima3D (https://www.mathworks.com/matlabcentral/fileexchange/17997-minimamaxima3d), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2006a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Feature Detection and Extraction 的更多信息
致谢

参考作品: extrema.m, extrema2.m

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0