Find peak (regions) in 2D data

后端 未结 1 1307
暗喜
暗喜 2020-12-31 13:43

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

相关标签:
1条回答
  • 2020-12-31 14:04

    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
    

    0 讨论(0)
提交回复
热议问题