资源简介
matlab函数,将多维矩阵的极值找出并定位,图像处理经常用到
代码片段和文件信息
function varargout = localMaximum(xminDist exculdeEqualPoints)
% function varargout = localMaximum(xminDist exculdeEqualPoints)
%
% This function returns the indexes\subscripts of local maximum in the data x.
% x can be a vector or a matrix of any dimension
%
% minDist is the minimum distance between two peaks (local maxima)
% minDist should be a vector in which each argument corresponds to it‘s
% relevant dimension OR a number which is the minimum distance for all
% dimensions
%
% exculdeEqualPoints - is a boolean definning either to recognize points with the same value as peaks or not
% x = [1 2 3 4 4 4 4 4 4 3 3 3 2 1];
% will the program return all the ‘4‘ as peaks or not - defined by the ‘exculdeEqualPoints‘
% localMaximum(x3)
% ans =
% 4 5 6 7 8 9 11 12
%
% localMaximum(x3true)
% ans =
% 4 7 12
%
%
% Example:
% a = randn(1003010);
% minDist = [10 3 5];
% peaks = localMaximum(aminDist);
%
% To recieve the subscript instead of the index use:
% [xIn yIn zIn] = localMaximum(aminDist);
%
% To find local minimum call the function with minus the variable:
% valleys = localMaximum(-aminDist);
if nargin < 3
exculdeEqualPoints = false;
if nargin < 2
minDist = size(x)/10;
end
end
if isempty(minDist)
minDist = size(x)/10;
end
xold=x;
dimX = length ( size(x) );
if length(minDist) ~= dimX
% In case minimum distance isn‘t defined for all of x dimensions
% I use the first value as the default for all of the dimensions
minDist = minDist( ones(dimX1) );
end
% validity checks
minDist = ceil(minDist);
minDist = max( [minDist(:)‘ ; ones(1length(minDist))] );
minDist = min( [minDist ; size(x)] );
% ---------------------------------------------------------------------
if exculdeEqualPoints
% this section comes to solve the problem of a plato
% without this code points with the same hight will be recognized as peaks
y = sort(x(:));
dY = diff(y);
% finding the minimum step in the data
minimumDiff = min( dY(dY ~= 0) );
%adding noise which won‘t affect the peaks
x = x + rand(size(x))*minimumDiff;
end
% ---------------------------------------------------------------------
se = ones(minDist);
X = imdilate(xse);
f = find(x == X & xold~=0);
% f = find(x == X);
if nargout
[varargout{1:nargout}] = ind2sub( size(x) f );
else
varargout{1} = f;
end
% first saving the original x
% xold=x;
% % exculdeEqualPoints
% x = x + rand(size(x))*minimumDiff;
% se = ones(minDist);
% X = imdilate(xse);
% f = find(x == X & xold~=0);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2962 2020-07-27 13:03 localMaximum.m
- 上一篇:CPHD的方法实现多目标跟踪
- 下一篇:交通标志图像分割
相关资源
- matlab填充图像边界内部
- 小波变换的水下图像目标检测
- matlab 深度学习toolbox(Deep Learn Toolbo
- 边界的声波逆时偏移
- SPIN_Matlab
- 石墨烯结构编程图
- 计算聚类算法评价指标之一
- Color transfer between images 非常经典的彩
- 受限玻尔兹曼机matlab源代码
- matlab植物叶片分类
- OCR MATLAB OCR中英文段落的提取、分割
- ssim衡量两幅图像相似度的指标
- matlab的流体计算和传热
- Fuzzy Neural Network by matlab 四个不同的
- 手机拍摄图像的二维码的提取
- 利用四元数对彩色图像作图像处理
- LBP方法
- 织物疵点检测和识别系统
- SAO星表数据
- 粒子群算法路径规划动画演示
- 新型的配电网潮流计算的matlab源码
- 雷达交叉定位精度分析
- 磁流变减震器模型
- D2D的自适应链路仿真
- matlab实现的读取视频和音频
- matlab平台DCT算法压缩视频
- Softmax 函数处理
- 《精通Matlab数字图像处理与识别》(
- 5阶WENO有限差分法求解Sod型激波管问题
- foa 果蝇优化算法matlab程序
评论
共有 条评论