在2D数据中查找峰(区域) [英] Find peak (regions) in 2D data

查看:254
本文介绍了在2D数据中查找峰(区域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在2D数据中找到峰值区域(如果您愿意,可以通过Hough变换创建灰度图像或2D景观)。通过峰值区域我的意思是局部最大峰值,但 不是单个点 ,而是周围的一部分<强大的> 贡献区域 随之而来。我知道,这是一个模糊的定义,但也许 mountain 这个词或下面的图片会让你直截了当地说出我的意思。



标记为红色(1-4)的峰是我想要的,粉红色(5-6)示例中的灰色区域,它会如果没有找到那些较小的峰值,那就没问题了。如果它们也没有问题。





图像包含1-20个峰值区域,高度不同。上面的冲浪图的2D数据如下所示,可能的结果(橙色对应峰值1,绿色对应峰值2 a / b,......)。测试的单个图像可以在描述链接中找到:



图像左



上面的结果是使用简单的阈值(MATLAB代码)生成的:

 %thresh_scale = 15; %参数:有多少阈值步骤
%thresh_perc = 6; %parameter:我们剪辑
thresh = multithresh(H,thresh_scale)的阈值;
q_image = imquantize(H,thresh);

q_image(q_image< = thresh_perc)= 0;阈值以下的%区域被抛弃
q_image(q_image> thresh_perc)= 1; %...而所有其他人都被保留了
q_image = imbinarize(q_image); %binarize用于进一步处理
B = bwareaopen(q_image,nhood_minsize); %过滤非常小的区域
[L,L_num] = bwlabel(B); %< - 结果%标签连接组件

像这些(15和6)这样的一些值通常可以正常工作如果几乎没有相似的峰值,但如果存在更多峰值或者它们变化很大,则这不一致。我主要有两个问题,也不能通过简单地调整参数来修复:




  • 更高的峰值可以掩盖更低(但可以清楚地区分) )峰值。由于阈值相对于最高峰值,其他峰值可能会低于。

  • 在某些情况下,两个峰值之间的谷值高于阈值,将几个峰值合并为一个峰值(可以观察到)与峰值2 a / b)。



我也不想要一个高峰值的巨大区域,所以峰值区域应该可能被定义为山的一定比例。我想而不是全局阈值,我宁愿有一种方法找到相对于它们的直接环境的峰值区域。我研究了均值平移和MSER分割,但这些似乎适合分割真实图像,而不是合成数据。



不知怎的,我想象用一定量的水填充景观的负面会给我我正在寻找的区域:盆地填充和扩散周围的方式区域形状。就像在图像下面浇水一样,产生的水池就是我正在寻找的区域。





我认为这就是洪水填充或分水岭算法所做的事情,但是洪水填充似乎完全是另外一种情况,分水岭结果根本不是我想到的,也是在应用一些我认为可以帮助的预处理时(截断为1/10) :





或使用时与上述示例相同的限幅阈值(截至6月15日):





使用此代码生成(M. ATLAB):

  thresh = multithresh(H,10); %设置为10 || 15示例
q_image = imquantize(H,thresh);
mask = false(size(q_image)); %创建剪贴蒙版...
mask(q_image> 1)= true; %...删除最低10%||最低6/15
%显示:数字,imshow(面具);

%可选:高斯平滑
H = imgaussfilt(H,2);在添加Inf值之前应用%
%可选:H-minima变换
H = imhmin(H,10); %参数是抑制浅层最小值的阈值
H = -H; %补充图像
H(〜mask)= Inf; %forceground像素为Inf

L =分水岭(D);
L(〜mask)= 0;来自结果
imshow的%clipground(label2rgb(L,'lines',[。5 .5 .5])); %显示结果






我的现在的问题: 是否有一种算法可以填充景观,并为我提供生成的水池(用于灌注各种水量)来完成我尝试用上述方法实现的目标?或欢迎任何其他建议。我正在实现MATLAB(或者如果需要Python),但我可以使用任何代码或pseude-code。



将此区别于


I am looking to find peak regions in 2D data (if you will, grayscale images or 2D landscapes, created through a Hough transform). By peak region I mean a locally maximal peak, yet NOT a single point but a part of the surrounding contributing region that goes with it. I know, this is a vague definition, but maybe the word mountain or the images below will give you an intuition of what I mean.

The peaks marked in red (1-4) are what I want, the ones in pink (5-6) examples for the "grey zone", where it would be okay if those smaller peaks are not found but also okay if they are.

Images contain between 1-20 peaked regions, different in height. The 2D data for above surf plot is shown below with a possible result (orange corresponds to Peak 1, green corresponds to Peak 2 a/b, ...). Single images for tests can be found in the description links:

Image left: input image - - - - middle: (okaish) result - - - - right: result overlayed over image.

The result above was produced using simple thresholding (MATLAB code):

% thresh_scale = 15;                     % parameter: how many thresholding steps 
% thresh_perc = 6;                       % parameter: threshold at which we clip
thresh = multithresh(H,thresh_scale);    
q_image = imquantize(H, thresh);         

q_image(q_image <= thresh_perc) = 0;     % regions under threshold are thrown away
q_image(q_image > thresh_perc) = 1;      % ... while all others are preserved
q_image = imbinarize(q_image);           % binarize for further processing
B = bwareaopen(q_image, nhood_minsize);  % Filter really small regions
[L, L_num] = bwlabel(B); % <- result     % Label connected components

Some values like these (15 and 6) often work fine if there are few similar peaks, but this isn't consistent if more peaks are present or they vary a lot. I mainly have two problems, that also can't be fixed by simply adjusting the parameters:

  • higher peaks can mask lower (but clearly distinguishable) peaks. Since the threshold is relative to the highest peak, other peaks may fall below.
  • in some cases the valley between two peaks is above the threshold, merging several peaks into one (as can be observed with Peak 2 a/b).

I also don't want a huge region for a high peak, so the peak region should probably be defined as some percentage of the mountain. I figured instead of a global thresholding, I'd rather have a method that finds peak regions relative to their immediate environment. I've looked into mean-shift and MSER segmentation, but those seem to be suited for segmenting real images, not kind of synthetic data.

Somehow I imagined filling a negative of the landscape with a certain amount of water would give me the regions I'm looking for: basins that fill and spread with how the surrounding regions are shaped. Like pouring water over below image and the resulting waterpools are the regions I'm looking for.

I thought that is what the floodfill or watershed algorithm do, but floodfill seems like something completely else and the watershed results are not at all what I had in mind, also when applying some preprocessing that I thought could help (clipped at 1/10):

Or when using the same clipping threshold as with above example (clipped at 6/15):

Produced with this code (MATLAB):

thresh = multithresh(H, 10);    % set to either 10 || 15 for the examples
q_image = imquantize(H, thresh);
mask = false(size(q_image));    % create clipping mask...
mask(q_image > 1) = true;       % ... to remove lowest 10% || lowest 6/15
                                % show with: figure, imshow(mask);

% OPTIONAL: Gaussian smoothing
H = imgaussfilt(H, 2);  % apply before adding Inf values
% OPTIONAL: H-minima transform
H = imhmin(H, 10);      % parameter is threshold for suppressing shallow minima
H = -H;                 % Complement the image
H(~mask) = Inf;         % force "ground" pixels to Inf

L = watershed(D);    
L(~mask) = 0;                               % clip "ground" from result
imshow(label2rgb(L,'lines',[.5 .5 .5]));    % show result


My question now: Is there an algorithm that fills a landscape and gives me the resulting waterpools (for various amounts of water poured) to do what I've tried to achieve with above methods? Or any other suggestion is welcome. I'm implementing MATLAB (or if need be Python), but I can work with any code or pseude-code.

To distinguish this from this question, my maxima are not separated by zero-values. What I want is similar, yet none of the suggestions there are helpful (hill-climbing/simulated annealing will give you only one point...).

This question is also interesting, but it solves the problem with constraints (assume exactly 5 peaks of a certain size) that make the suggested approaches not useful for my case.

解决方案

In such peak finding problems, I mostly use morphological operations. Since the Hough transform results are mostly noisy, I prefer blurring it first, then apply tophat and extended maxima transform. Then for each local maximum, find the region around it with adaptive thresholding. Here is a sample code:

im=imread('udIuy.png');

% blur
im=imgaussfilt(im,1);

% tophat transform
im2=imtophat(im,strel('disk',5));

% extended maximums
im3=imextendedmax(im2,10);

% Extract each blob
s=regionprops(im3,'Centroid','PixelIdxList');

figure,imagesc(im),axis image

for i=1:numel(s)
    x=ceil(s(i).Centroid);
    tmp=im*0;
    tmp(s(i).PixelIdxList)=1;
    tmp2=tmp.*im2;

% The maximum amplitude and location

    [refV,b]=max(tmp2(:));
    [x2,y2]=ind2sub(size(im),b);

% select the region around local max amplitude    
    tmp=bwselect(im2>refV*0.6,y2,x2,4);  

    [xi,yi]=find(tmp);
    hold on, plot(yi,xi,'r.')
    hold on, text(y2+10,x2,num2str(i),'Color','white','FontSize',16)    
end

这篇关于在2D数据中查找峰(区域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆