史蒂夫在图像处理与matlab

图像处理概念,算法和matlab

Small-Peak Suppression with the H-Maxima Transform

上次 ,我介绍了一个想法 区域最大值 。今天,我想添加一个使区域最大更有用的概念:抑制非常小的局部最大值,可能仅由于噪音而存在,即在识别区域最大值之前是不重要的。这种“小峰值抑制”可以使用称为的东西来完成 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 。我想使用一维的例子详细说明。
y = peaksandplateaus.;
x = 1:length(y);
绘图(x,y)
axis([-5 105 0 120])
grid
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.
Tiledlayout(2,2)
nextdile.
绘图(x,y)
抓住
绘图(x(plateau_mask),y(plateau_mask),“*”的)
抓住离开
轴([0 40 40 60])
grid
text(20,52,“区域最大”,横向="center"的)
nextdile.
绘图(x,y)
抓住
绘图(x(plateau_mask),y(plateau_mask),“*”的)
抓住离开
轴([40 60 10 30])
grid
文字(47,14,["regional" "minimum"],HorizontalAlignment ="center"。。。
VerticalAlignment ="top"的)
text(55,14,["regional" "minimum"],HorizontalAlignment ="center"。。。
VerticalAlignment ="top"的)
文字(51,19,[“区域”“最大”],HorizontalAlignment ="center"。。。
VerticalAlignment =“底部”的)
nextdile.
绘图(x,y)
抓住
绘图(x(plateau_mask),y(plateau_mask),“*”的)
抓住离开
轴([58 69 40 95])
grid
文字(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);
Tiledlayout(3,2)
nextdile.
绘图(x,y)
axis([-5 105 0 120])
grid
title(“输入曲线”的)
nextdile.
plot(x,reg_max_mask)
轴([ - 5 105 -0.05 1.05])
grid
title("Output of imregionalmax"的)
nextdile.([2 2])
绘图(x,y)
抓住
绘图(x(reg_max_mask),y(reg_max_mask),“*”的)
抓住离开
axis([-5 105 0 120])
grid
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 即使是最微小的局部最大值也是如此。让我们试试吧。如果我添加了非常少量的噪音,你甚至不能在剧情中看到它:
rng(17)
Yn = Y +(0.01 * RANDN(尺寸(y)));
CLF.
plot(x,yn)
axis([-5 105 0 120])
grid
但现在输出 imregionalmax 看起来完全不同。
reg_max_mask_n = imregionalmax(yn);
plot(x,yn)
抓住
绘图(x(reg_max_mask_n),yn(reg_max_mask_n),“*”的)
抓住离开
axis([-5 105 0 120])
grid
现在,只有宽平台上的样品散射被确定为区域最大值,小“肩部”高原上的样品被标记为未以前的区域最大值。我们必须放大很远,看看为什么发生这种情况。
轴([5 20 49.8 50.1])
轴([62 67 79.9 80.2])
您可以看到添加的噪音正在各个地方引入微小的本地最大值,并且正在抛出 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 像这样:
YN_H = IMHMAX(YN,5);
plot(x,yn)
抓住
绘图(x,yn_h)
抓住离开
axis([-5 105 0 120])
grid
传奇([“原始”“H-Maxima变换”])
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);
plot(x,yn)
抓住
绘图(x(reg_max_mask_n_h),yn(reg_max_mask_n_h),“*”的)
抓住离开
axis([-5 105 0 120])
grid
通过该计算,我们只识别出明显高于它们周围的峰值,而且通常是我们感兴趣的。注意 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
如果您在自己的工作中找到了这些功能的有趣用途,我很乐意听到它,所以请留下评论。

实用功能

功能y = peaksandplateaus.
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));
g5 = @(x) 30*f((x-60));
g = @(x)g1(x)+ g2(x)+ g3(x)+ g4(x)+ g5(x);
Y =圆形(g(0:100));
结尾
|
  • 打印
  • 发送电子邮件

댓글

댓글을 남기려면링크를클릭하여mathworks계정계정에로그인하거나하거나을새로새로새로