Reply by Vladimir Vassilevsky March 29, 20102010-03-29

Michael Plante wrote:

> Luna Moon wrote: > >>On Mar 24, 8:12=A0pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >> >>>Luna Moon wrote: >>> >>>>Hi all, >>> >>>>We have a task in Matlab that I don't know how to it: >>> >>>>We would like to find the "robust" peak/max in an numeric array. >>> >>>>The "robust" here means that if the peak or max is a singleton and > > all > >>>>the surrounding regions around that peak/spike/max are deep valleys, >>>>then this peak/max is not a "robust" max, it's a spike, or random >>>>noise. >>> >>>>We don't want to get such a max. >>> >>>>Instead, we would like to see a slow varying top, or stable flat top. >>>>We would like to see that if the surrounding regions around the peak/ >>>>max are also high values, then that peak/max is a "robust" max, it's >>>>not a spike or random noise. >>> >>>>How do I fulfill this task in Matlab? >>> >>>Lowpass your data, find maximum, then refine the position of maximum >>>over the initial data. >>> >>>And remember: MATLAB is for STUPIDENTS and toy problems. >>> >>>VLV >> >>Do you think low-pass filter will work here? >> >>Let's say you have the following shape: >> >> >>1 1 1 1 1 >>1 0 0 0 1 >>1 0 2 0 1 >>1 0 0 0 1 >>1 1 1 1 1 >> >>Let's say I don't want to identify the 2 in the middle as my peak. >>Because that's a spike which is not robust. >> >>I suspect a low pass filter will still pick that 2 up... > > > > Try a median filter first? For example, run a 3x3 block over the whole > image and replace the center at each point with the median of the 9 > values.
1. Highpass 2. Clip the peaks 3. Lowpass 4. Find peaks 5. Refine peak positions wrt original data Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by Michael Plante March 29, 20102010-03-29
Luna Moon wrote:
>On Mar 24, 8:12=A0pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >> Luna Moon wrote: >> > Hi all, >> >> > We have a task in Matlab that I don't know how to it: >> >> > We would like to find the "robust" peak/max in an numeric array. >> >> > The "robust" here means that if the peak or max is a singleton and
all
>> > the surrounding regions around that peak/spike/max are deep valleys, >> > then this peak/max is not a "robust" max, it's a spike, or random >> > noise. >> >> > We don't want to get such a max. >> >> > Instead, we would like to see a slow varying top, or stable flat top. >> > We would like to see that if the surrounding regions around the peak/ >> > max are also high values, then that peak/max is a "robust" max, it's >> > not a spike or random noise. >> >> > How do I fulfill this task in Matlab? >> >> Lowpass your data, find maximum, then refine the position of maximum >> over the initial data. >> >> And remember: MATLAB is for STUPIDENTS and toy problems. >> >> VLV > >Do you think low-pass filter will work here? > >Let's say you have the following shape: > > >1 1 1 1 1 >1 0 0 0 1 >1 0 2 0 1 >1 0 0 0 1 >1 1 1 1 1 > >Let's say I don't want to identify the 2 in the middle as my peak. >Because that's a spike which is not robust. > >I suspect a low pass filter will still pick that 2 up...
Try a median filter first? For example, run a 3x3 block over the whole image and replace the center at each point with the median of the 9 values.
Reply by Sebastian Doht March 29, 20102010-03-29
Luna Moon schrieb:
> On Mar 24, 8:12 pm, Vladimir Vassilevsky<nos...@nowhere.com> wrote: >> Luna Moon wrote: >>> Hi all, >> >>> We have a task in Matlab that I don't know how to it: >> >>> We would like to find the "robust" peak/max in an numeric array. >> >>> The "robust" here means that if the peak or max is a singleton and all >>> the surrounding regions around that peak/spike/max are deep valleys, >>> then this peak/max is not a "robust" max, it's a spike, or random >>> noise. >> >>> We don't want to get such a max. >> >>> Instead, we would like to see a slow varying top, or stable flat top. >>> We would like to see that if the surrounding regions around the peak/ >>> max are also high values, then that peak/max is a "robust" max, it's >>> not a spike or random noise. >> >>> How do I fulfill this task in Matlab? >> >> Lowpass your data, find maximum, then refine the position of maximum >> over the initial data. >> >> And remember: MATLAB is for STUPIDENTS and toy problems. >> >> VLV > > Do you think low-pass filter will work here? > > Let's say you have the following shape: > > > 1 1 1 1 1 > 1 0 0 0 1 > 1 0 2 0 1 > 1 0 0 0 1 > 1 1 1 1 1 > > Let's say I don't want to identify the 2 in the middle as my peak. > Because that's a spike which is not robust. > > I suspect a low pass filter will still pick that 2 up... > > Any more thoughts? > > Thank you!
Maybe you could apply some robust fitting method like RANSAC or anything else suitable for outlier detection if you can come up with a good model your input data is most likely to follow. But you need much bigger arrays than the example to distinguish between a spike/outlier and a real data point.
Reply by ImageAnalyst March 29, 20102010-03-29
Luna:
This is not an easy problem.  It's harder in 2D than it is for 1D
signals.

You might want to look into H-domes.
http://www.afscet.asso.fr/resSystemica/Crete02/Halkiotis.pdf
http://www.leptonica.com/grayscale-morphology.html#TOPHAT-HDOME

This is done in MATLAB by the function imhmax() function in the image
processing toolbox.  You might also take a look at imregionalmax() and
imextendedmax().
Good luck,
ImageAnalyst
Reply by Tim Wescott March 29, 20102010-03-29
Jerry Avins wrote:
> Luna Moon wrote: >> On Mar 24, 8:12 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >>> Luna Moon wrote: >>>> Hi all, >>>> We have a task in Matlab that I don't know how to it: >>>> We would like to find the "robust" peak/max in an numeric array. >>>> The "robust" here means that if the peak or max is a singleton and all >>>> the surrounding regions around that peak/spike/max are deep valleys, >>>> then this peak/max is not a "robust" max, it's a spike, or random >>>> noise. >>>> We don't want to get such a max. >>>> Instead, we would like to see a slow varying top, or stable flat top. >>>> We would like to see that if the surrounding regions around the peak/ >>>> max are also high values, then that peak/max is a "robust" max, it's >>>> not a spike or random noise. >>>> How do I fulfill this task in Matlab? >>> Lowpass your data, find maximum, then refine the position of maximum >>> over the initial data. >>> >>> And remember: MATLAB is for STUPIDENTS and toy problems. >>> >>> VLV >> >> Do you think low-pass filter will work here? >> >> Let's say you have the following shape: >> >> >> 1 1 1 1 1 >> 1 0 0 0 1 >> 1 0 2 0 1 >> 1 0 0 0 1 >> 1 1 1 1 1 >> >> Let's say I don't want to identify the 2 in the middle as my peak. >> Because that's a spike which is not robust. >> >> I suspect a low pass filter will still pick that 2 up... > > Of course it will, because it's the closest thing to a peak that there > is. Never mind how to program it. If you, with all your intelligence, > can't provide an answer for a simple case, what hope do you have of > instructing a machine to do it for you? > > Jerry
I think the OP's problem is that she has an image with popcorn noise or some such, and she wants to pick out a "true" peak without triggering on noise. If that's really the case, then ponder her example with the '2' turned to a '20', or all the '1's turned to 0.1. Although that does raise the question of why she doesn't want to just filter out the popcorn noise separately, then go looking for peaks. Hopefully we'll get some clarification... -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Reply by Jerry Avins March 29, 20102010-03-29
Luna Moon wrote:
> On Mar 24, 8:12 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >> Luna Moon wrote: >>> Hi all, >>> We have a task in Matlab that I don't know how to it: >>> We would like to find the "robust" peak/max in an numeric array. >>> The "robust" here means that if the peak or max is a singleton and all >>> the surrounding regions around that peak/spike/max are deep valleys, >>> then this peak/max is not a "robust" max, it's a spike, or random >>> noise. >>> We don't want to get such a max. >>> Instead, we would like to see a slow varying top, or stable flat top. >>> We would like to see that if the surrounding regions around the peak/ >>> max are also high values, then that peak/max is a "robust" max, it's >>> not a spike or random noise. >>> How do I fulfill this task in Matlab? >> Lowpass your data, find maximum, then refine the position of maximum >> over the initial data. >> >> And remember: MATLAB is for STUPIDENTS and toy problems. >> >> VLV > > Do you think low-pass filter will work here? > > Let's say you have the following shape: > > > 1 1 1 1 1 > 1 0 0 0 1 > 1 0 2 0 1 > 1 0 0 0 1 > 1 1 1 1 1 > > Let's say I don't want to identify the 2 in the middle as my peak. > Because that's a spike which is not robust. > > I suspect a low pass filter will still pick that 2 up...
Of course it will, because it's the closest thing to a peak that there is. Never mind how to program it. If you, with all your intelligence, can't provide an answer for a simple case, what hope do you have of instructing a machine to do it for you? Jerry -- Discovery consists of seeing what everybody has seen, and thinking what nobody has thought. .. Albert Szent-Gyorgi &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
Reply by Luna Moon March 29, 20102010-03-29
On Mar 24, 8:12&#2013266080;pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> Luna Moon wrote: > > Hi all, > > > We have a task in Matlab that I don't know how to it: > > > We would like to find the "robust" peak/max in an numeric array. > > > The "robust" here means that if the peak or max is a singleton and all > > the surrounding regions around that peak/spike/max are deep valleys, > > then this peak/max is not a "robust" max, it's a spike, or random > > noise. > > > We don't want to get such a max. > > > Instead, we would like to see a slow varying top, or stable flat top. > > We would like to see that if the surrounding regions around the peak/ > > max are also high values, then that peak/max is a "robust" max, it's > > not a spike or random noise. > > > How do I fulfill this task in Matlab? > > Lowpass your data, find maximum, then refine the position of maximum > over the initial data. > > And remember: MATLAB is for STUPIDENTS and toy problems. > > VLV
Do you think low-pass filter will work here? Let's say you have the following shape: 1 1 1 1 1 1 0 0 0 1 1 0 2 0 1 1 0 0 0 1 1 1 1 1 1 Let's say I don't want to identify the 2 in the middle as my peak. Because that's a spike which is not robust. I suspect a low pass filter will still pick that 2 up... Any more thoughts? Thank you!
Reply by Vladimir Vassilevsky March 24, 20102010-03-24

Luna Moon wrote:

> Hi all, > > We have a task in Matlab that I don't know how to it: > > We would like to find the "robust" peak/max in an numeric array. > > The "robust" here means that if the peak or max is a singleton and all > the surrounding regions around that peak/spike/max are deep valleys, > then this peak/max is not a "robust" max, it's a spike, or random > noise. > > We don't want to get such a max. > > Instead, we would like to see a slow varying top, or stable flat top. > We would like to see that if the surrounding regions around the peak/ > max are also high values, then that peak/max is a "robust" max, it's > not a spike or random noise. > > How do I fulfill this task in Matlab?
Lowpass your data, find maximum, then refine the position of maximum over the initial data. And remember: MATLAB is for STUPIDENTS and toy problems. VLV
Reply by Tim Wescott March 24, 20102010-03-24
Luna Moon wrote:
> Hi all, > > We have a task in Matlab that I don't know how to it: > > We would like to find the "robust" peak/max in an numeric array. > > The "robust" here means that if the peak or max is a singleton and all > the surrounding regions around that peak/spike/max are deep valleys, > then this peak/max is not a "robust" max, it's a spike, or random > noise. > > We don't want to get such a max. > > Instead, we would like to see a slow varying top, or stable flat top. > We would like to see that if the surrounding regions around the peak/ > max are also high values, then that peak/max is a "robust" max, it's > not a spike or random noise. > > How do I fulfill this task in Matlab? > > Thanks a lot!
Does Matlab have a "find" function, to find the index of an array element? In Scilab you'd do ix = find(array = max(array)). That would get you the position in one dimension of the maximum (or maxima); then you'd have to get that into 2D, then you'd have to check the neighbors. I suspect Matlab lets you do something similar. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Reply by Luna Moon March 24, 20102010-03-24
Hi all,

We have a task in Matlab that I don't know how to it:

We would like to find the "robust" peak/max in an numeric array.

The "robust" here means that if the peak or max is a singleton and all
the surrounding regions around that peak/spike/max are deep valleys,
then this peak/max is not a "robust" max, it's a spike, or random
noise.

We don't want to get such a max.

Instead, we would like to see a slow varying top, or stable flat top.
We would like to see that if the surrounding regions around the peak/
max are also high values, then that peak/max is a "robust" max, it's
not a spike or random noise.

How do I fulfill this task in Matlab?

Thanks a lot!