20060410-Quick tip: Determining uniqueness of local maximum

本文探讨了局部最大值过滤的概念及其在图像处理中的应用。通过使用MATLAB函数,展示了如何使用形态学膨胀计算整个图像的局部最大值,并提供了一种使用排序算子过滤器两次来确定局部最大值独特性的具体方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文:http://blogs.mathworks.com/steve/2006/04/10/quick-tip-determining-uniqueness-of-neighborhood-maximum/

Let's review first the concept of a local maximum filter. This image operator replaces every pixel value with the maximum pixel value found in a neighborhood surrounding the pixel. For example:

a = magic(5)
What should the output be for a local maximum filter using 3-by-3 neighborhoods?

neighborhood = a(2:4, 1:3)
Local maximum filtering is the same as morphological dilation, so I usually use imdilate to compute the result for the entire image:
b = imdilate(a, ones(3,3))

I suggest using ordfilt2 twice. This function is for ''two-dimensional order-statistic filtering.'' This operation replaces every pixel value with the n-th sorted pixel value in its neighborhood. It uses an ascending sort order, so if n is the number of pixels in the neighborhood, the operation is exactly equivalent to the local maximum filter.

The specific procedure is:

  1. Call ordfilt2 to get the highest pixel values in each neighborhood.
  2. Call ordfilt2 again to get the second-highest pixel values in each neighborhood.
  3. Determine where the outputs of steps 1 and 2 are equal. Wherever they are equal, the local maximum is not unique.

Let's try an example. First, modify our original matrix a bit:

ap = a;
ap(3,4) = 22
Get the highest pixel values in each 3-by-3 neighborhood:

highest = ordfilt2(ap, 9, ones(3,3))
Get the second-highest pixel values:

second_highest = ordfilt2(ap, 8, ones(3,3))
Determine where the highest and second highest pixel values are equal:
non_unique_maxima_mask = (highest == second_highest)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值