+ Post New Thread
Results 1 to 14 of 14
  1. #1
    Newbie level 4
    Points: 34, Level: 1

    Join Date
    Apr 2017
    Posts
    5
    Helped
    0 / 0
    Points
    34
    Level
    1

    peak valley detection

    Hi,
    I intend to detect a valley which preceds a large peak in a set of values. Attaching an image for your reference. I should not detect any other valleys. Please let me know if it is possible or not. I intend to detect only the valleys denoted by blue point.
    Thanks

    Click image for larger version. 

Name:	1_crop.jpg 
Views:	13 
Size:	121.2 KB 
ID:	137989

    •   Alt17th April 2017, 18:45

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 18,297, Level: 32
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    3,510
    Helped
    762 / 762
    Points
    18,297
    Level
    32

    Re: peak valley detection

    you need to set some value "delta". If the difference between two adjacent points is greater than that delta, you've found a valley.



  3. #3
    Super Moderator
    Points: 22,939, Level: 36
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Portugal
    Posts
    6,970
    Helped
    853 / 853
    Points
    22,939
    Level
    36
    Blog Entries
    5

    Re: peak valley detection

    There are a lot of algorithms on the web covering the subject "peak detection". You could somehow to invert the above graph ( eg. subtracting tha current value from the maximum ) to make use of some of these algorithms to find the points where the maximum ( actually, the minimum ) occurs.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  4. #4
    Newbie level 4
    Points: 34, Level: 1

    Join Date
    Apr 2017
    Posts
    5
    Helped
    0 / 0
    Points
    34
    Level
    1

    Re: peak valley detection

    Quote Originally Posted by barry View Post
    you need to set some value "delta". If the difference between two adjacent points is greater than that delta, you've found a valley.
    the issue is am not sure about the delta it varies all along.



    •   Alt18th April 2017, 11:31

      advertising

        
       

  5. #5
    Advanced Member level 5
    Points: 18,297, Level: 32
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    3,510
    Helped
    762 / 762
    Points
    18,297
    Level
    32

    Re: peak valley detection

    You need to define your criteria better. For example, why does that second unmarked minimum not qualify as what you are calling a 'valley'? Is it because it is not far enough away from the adjacent peaks? Is it because it is not below some absolute threshold? Is a'valley' valid relative only to a previous peak, or to previous and subsequent peaks? If you took the derivative of your data you could find minima that way?



  6. #6
    Newbie level 4
    Points: 34, Level: 1

    Join Date
    Apr 2017
    Posts
    5
    Helped
    0 / 0
    Points
    34
    Level
    1

    Re: peak valley detection

    the plot represents the intensity value along the horizontal. So my target is to extract the region where the intensity rises drastically hence I am not concerned about the second valley. thats the reason its becoming difficult for me.



    •   Alt18th April 2017, 18:47

      advertising

        
       

  7. #7
    Advanced Member level 5
    Points: 18,297, Level: 32
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    3,510
    Helped
    762 / 762
    Points
    18,297
    Level
    32

    Re: peak valley detection

    Quote Originally Posted by jenthom View Post
    the plot represents the intensity value along the horizontal. So my target is to extract the region where the intensity rises drastically hence I am not concerned about the second valley. thats the reason its becoming difficult for me.
    You're losing me. What do you mean "the intensity value along the horizontal"? It doesn't matter; you've got some data plotted in an x-y plane. The slope ("intensity rise", as you seem to call it) of the unaccepted valley looks the same as at your other valleys. There must be some other criteria you are using.



  8. #8
    Super Moderator
    Points: 26,259, Level: 39
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    5,958
    Helped
    1462 / 1462
    Points
    26,259
    Level
    39

    Re: peak valley detection

    From your description you want some sort of algorithm to detect a rise in intensity that exceeds some previous N samples before saying a valley has been detected. That is why the 2nd valley isn't detected because the first peak to second value to next peak occurs too rapidly and the peaks are nearly the same height?

    If so use some sort of filtering algorithm as you scan through the data to determine if the duration of a valley is long enough and the next peak is higher than that filter output. Perhaps a simple boxcar (or moving) average would suffice to tell you if the rise in the peak following a valley is greater than some minimum threshold. This would also not detect peaks that rise too slowly as the boxcar average would likely be over the minimum.



  9. #9
    Super Moderator
    Points: 22,939, Level: 36
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Portugal
    Posts
    6,970
    Helped
    853 / 853
    Points
    22,939
    Level
    36
    Blog Entries
    5

    Re: peak valley detection

    According to my own experience, each kind of data require a specific treatment, and you'll have to make experiments to better feel what it is necessary. In other words, there will be needed to use all those concepts mentioned above, but having to adjust parameters, or even to swap the order of the execution of some functions.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  10. #10
    Newbie level 4
    Points: 34, Level: 1

    Join Date
    Apr 2017
    Posts
    5
    Helped
    0 / 0
    Points
    34
    Level
    1

    Re: peak valley detection

    I am sorry if i didnt make any sense but with varying intensity value I mean the variation of black pixels along the horizontal so the first column represent the sum of pixels that are black in the first column and so on...so I make a plot of this data which is shown here. So I am not interested in small valleys as the variation is less there. May be I could keep some threshold for detecting the valleys, but still the question arises how will I detect if its a valley. I am very new to this so pardon me if I am not able to be very clear.



    •   Alt19th April 2017, 05:07

      advertising

        
       

  11. #11
    Super Moderator
    Points: 26,259, Level: 39
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    5,958
    Helped
    1462 / 1462
    Points
    26,259
    Level
    39

    Re: peak valley detection

    Then maybe something simpler like a sliding window with a check for a (MAX/MIN> threshold) AND (MINx < MAXx), that would be pretty easy to implement.



  12. #12
    Super Moderator
    Points: 22,939, Level: 36
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Portugal
    Posts
    6,970
    Helped
    853 / 853
    Points
    22,939
    Level
    36
    Blog Entries
    5

    Re: peak valley detection

    Quote Originally Posted by ads-ee View Post
    Then maybe something simpler like a sliding window with a check for a (MAX/MIN> threshold) AND (MINx < MAXx), that would be pretty easy to implement.
    I would improve this method with barry's advice:
    Taking the local MIN together with a derivative of the window could give a more strong metric.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  13. #13
    Newbie level 4
    Points: 34, Level: 1

    Join Date
    Apr 2017
    Posts
    5
    Helped
    0 / 0
    Points
    34
    Level
    1

    Re: peak valley detection

    by sliding window should I calculating the moving average ? Or do you mean to calculate the min and max in the sliding window range.



  14. #14
    Super Moderator
    Points: 230,274, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    39,750
    Helped
    12130 / 12130
    Points
    230,274
    Level
    100

    Re: peak valley detection

    by sliding window should I calculating the moving average ? Or do you mean to calculate the min and max in the sliding window range.
    Whatever they meaned, how about trying the significance of different criteria for your data yourself?



--[[ ]]--