Skip to content

reg peak detection

3 messages · SHRIRAM R SAMPAT, Jim Porzak, Tom

#
Hallo everybody,

I am doing a thesis in video extensometry and one my
approaches requires peak detection in a two
dimensional data.

If would be grateful if anyone can throw some light on
this for me by giving me some hints on how to do it or
give me some links for it.

thank very much in advance.

Ram
Tom
#
Having missed last months thread I reinvented the wheel. I thought I'd
post my code here for fun and feedback.

getDerivation<-function(v_dataset){
    #setup a vector to hold derivations
    v_deriv<-vector(length=length(v_dataset)-1)

    for(iLoc in 2:length(v_dataset)){
        v_deriv[iLoc-1]<-v_dataset[iLoc]-v_dataset[iLoc-1]
    }
    return(v_deriv)
}
getPeaks<-function(v_deriv){
    v_deriv<-sign(as.numeric(v_deriv))
    v_temp<-vector(length=length(v_deriv)-1)

    for(iLoc in 1:length(v_deriv)-1){
        v_temp[iLoc]<-v_deriv[iLoc]+v_deriv[iLoc+1]
    }
    v_peaks<-which(abs(v_temp)<=1)+1
    return(v_peaks)
}

set.seed(2)
x <- round(rnorm(1000000), 2)
y <- cumsum(x)

system.time(deriv<-getDerivation(y))
[1] 9.61 0.03 9.90 0.00 0.00
system.time(peaks<-getPeaks(deriv))
[1] 8.76 0.12 9.11 0.00 0.00

(Times shown are on an AMD64 3400+)

Regards
Tom

**An hour in the library is worth 8 in the lab**
On Thu, 2005-08-12 at 14:25 -0800, Jim Porzak wrote: