上次
,我介绍了一个想法
区域最大值
。今天,我想添加一个使区域最大更有用的概念:抑制非常小的局部最大值,可能仅由于噪音而存在,即在识别区域最大值之前是不重要的。这种“小峰值抑制”可以使用称为的东西来完成
H-maxima transform.
The functions of interest today:
imregionalmax
那
imhmax
那
imextendedmax.
那
ImregionalMin.
那
伊姆曼
, 和
imextendedmin
。
通过再次开始定义,让我们到达那里
区域最大值
: a connected component of pixels with a constant value
H
那where every pixel that is neighbor to that connected component has a value that is lower than
H
。我想使用一维的例子详细说明。
I'll use dilation and erosion to identify curve samples that are on plateaus.
plateau_mask = (y == imdilate(y,[1 1 1])) & (y == imerode(y,[1 1 1]));
plateau_mask = imdilate(plateau_mask,[1 1 1]);
绘图(x(plateau_mask),y(plateau_mask),“*”的)
Here are some zoomed-in views that illustrate three kinds of plateaus that are of interest.
绘图(x(plateau_mask),y(plateau_mask),“*”的)
text(20,52,“区域最大”,横向="center"的)
绘图(x(plateau_mask),y(plateau_mask),“*”的)
文字(47,14,["regional" "minimum"],HorizontalAlignment ="center"那。。。
VerticalAlignment ="top"的)
text(55,14,["regional" "minimum"],HorizontalAlignment ="center"那。。。
VerticalAlignment ="top"的)
文字(51,19,[“区域”“最大”],HorizontalAlignment ="center"那。。。
VerticalAlignment =“底部”的)
绘图(x(plateau_mask),y(plateau_mask),“*”的)
文字(66,83,“高原”,横向="right"的)
text(64,79,[“不是区域最大”“不是区域分钟”],。。。
HorizontalAlignment ="left"那VerticalAlignment ="top"的)
As I showed last time, the function
imregionalmax
identifies the location of regional maxima. These can be individual samples or pixels, or they can be plateaus. Take a look:
reg_max_mask = imregionalmax(y);
title("Output of imregionalmax"的)
绘图(x(reg_max_mask),y(reg_max_mask),“*”的)
title("Regional maxima plateaus"的)
我一直在尝试的曲线相对光滑,具有完全平坦的平稳。不幸的是,这
imregionalmax
is significantly less useful when the input is even a little noisy. That's because noise introduces small local maxima in many places, and
imregionalmax
即使是最微小的局部最大值也是如此。让我们试试吧。如果我添加了非常少量的噪音,你甚至不能在剧情中看到它:
Yn = Y +(0.01 * RANDN(尺寸(y)));
但现在输出
imregionalmax
看起来完全不同。
reg_max_mask_n = imregionalmax(yn);
绘图(x(reg_max_mask_n),yn(reg_max_mask_n),“*”的)
现在,只有宽平台上的样品散射被确定为区域最大值,小“肩部”高原上的样品被标记为未以前的区域最大值。我们必须放大很远,看看为什么发生这种情况。
您可以看到添加的噪音正在各个地方引入微小的本地最大值,并且正在抛出
imregionalmax
从我们想要的东西中脱离了香味。
imhmax
And here's where the function
imhmax
发挥作用了。计算的
H-maxima
transform. This operation essentially suppresses any local maxima that are less than a certain height (
H
的)above their immediate surroundings. Let's say, for example, that we are only interested in local or regional maxima that have a height of more than 5 units above their immediate surroundings. We accomplish this by calling
imhmax
像这样:
In the output of
imhmax
那the broad peaks have been flattened out, and the small peak in the middle, which has a height of only 3 above its surroundings, has been flattened out and eliminated. Now let's try
imregionalmax
again.
reg_max_mask_n_h = imregionalmax(yn_h);
绘图(x(reg_max_mask_n_h),yn(reg_max_mask_n_h),“*”的)
通过该计算,我们只识别出明显高于它们周围的峰值,而且通常是我们感兴趣的。注意
H-maxima
变换传播峰值一点,因此上面所示的结果是挑选每个广泛高原的左右的“肩部”的一点。如有必要,我们可以做一些后处理来纠正该后处理。
还有另一种功能,
imextendedmax.
那that simply combines the h-maxima transform and regional maxima steps into a single function. If you're interested in minima instead, then you can use the upside-down versions of these functions:
伊姆曼
那
ImregionalMin.
, 和
imextendedmin
。
如果您在自己的工作中找到了这些功能的有趣用途,我很乐意听到它,所以请留下评论。
实用功能
f = @(x)min(max(1-abs(x / 5),0),0.5);
g1 = @(x)100 * f((x-20)/ 5);
g2 = @(x) 200*f((x-80)/5);
g3 = @(x)30 * f((x-50)/ 3);
g4 = @(x)5 * f(2 *(x-50));
g = @(x)g1(x)+ g2(x)+ g3(x)+ g4(x)+ g5(x);
댓글
댓글을 남기려면링크를클릭하여mathworks계정계정에로그인하거나하거나을새로새로새로