Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding 2d impulse peaks in MATLAB

What is the best method for finding impulse peaks (dirac delta) in a 2d matrix.

More specifically, I would like to find the harmonic frequencies of a given image and so I need to find impulse peaks in the image absolute value DFT.

I thought of using findpeaks but there's no 2d version. I also saw earlier posts regarding finding ordinary peaks using imdilate and/or imextendedmax but those find all the peaks in a 2d matrix whereas I am only interested in impulse peaks. I am sure DSP people have a common recipe for this...

Please Help,

Thanks

like image 726
smichak Avatar asked Feb 25 '23 18:02

smichak


1 Answers

What you want to do is find peaks with high contrast. Thus, you need a way to identify local maxima, plus a way to measure the difference between the peak and the surrounding values. Thresholding on this difference will identify the impulse peaks for you.

Assuming your input signal is called signal

%# dilate to find, for every pixel, the maximum of its neighbors
dilationMask = ones(3);
dilationMask(5) = 0;
dilSignal = imdilate(signal, dilationMask);

%# find all peaks
%# peaks = signal > dilSignal;

%# find large peaks peaks by thresholding, i.e. you accept a peak only 
%# if it's more than 'threshold' higher than its neighbors
peaks = (signal - dilSignal) > threshold;

peaks is a logical array with 1's wherever there is a good peak. You can use it to read peak heights from signal with signal(peaks), and to find coordinates using find(peaks).

like image 150
Jonas Avatar answered Mar 03 '23 15:03

Jonas