Detecting trough widths and locations in 1d signal I have the following function obtained from averaging 2d camera image over one axis, where detection of aligned objects is desired:



I need to detect (roughly speaking) locations and widths of the troughs -- sometimes and object will be missing, thus the trough will be much wider. The approach should have some resilience WRT possible lighting variations and other noise; this, and also a desire to use something new and useful) prevents me from going the naive way of thresholding and clustering or something similar.

I was looking at using wavelets: using ideal trough (Haar?) as the mother wavelet function, and the analysis would give its translation and scale at troughs in the signal. 

I have no prior experience with wavelets. My background is numerics (variational analysis/FEM, particle systems programming), c++ and python, but I am quite new to signal processing (and its terminology).

What would be the most suitable thing to do? Suggestions, pointers to articles, books, or, best, code examples are much appreciated.

EDIT:

I finally used continuous wavelet transform (as implemented in scipy) where the result local maxima (in yellow) show both location (x-axis) and width (y-axis) of the trough.

import numpy as np
from scipy import signal
# scale the ricker (mexican hat) function to 10-60px width
widths=np.arange(10,60,.2)
cwtout=signal.cwt(vscan,signal.ricker,widths)
plt.imshow(cwtout,extent=[0,len(vscan),60,10],aspect='auto',vmax=abs(cwtout).max(),vmin=abs(cwtout).min())
A wavelet analysis or wavelet transform will give you scale(frequency) vs time vs amplitude. I am not sure how that will help you with your problem. 
Here is an algorithm for wavelet transform :


Choose your wavelet : Haar , Molet etc ..say $ \psi (n) $ 
Choose Scale : the scale should be a multiple of smallest time interval dt. 
Calculate the FFT of wavelet - $\Psi_0 (s\omega _k)$
Normalise FFT of the Wavelet - $ \Psi (s\omega_k)=(2\pi s / \delta t)\Psi_0 (s\omega _k)$
Find FFT of time series x(t) = $ X_k = 1/N  \sum_{k=0}^{N-1} x(n) e^{-2\pi i k n/N } $
Then Wavelet transform is : 
  $ W(s)= \sum_{k=0}^{N-1} X_k\Psi^* (s\omega_k) e^ {i\omega_k n \delta t} $    ...where * is complex conjugate 
Generally the Fourier transform of the wavelet should be known analytically. 


Few good sources : 


http://paos.colorado.edu/research/wavelets/bams_79_01_0061.pdf
http://users.rowan.edu/~polikar/WAVELETS/WTpart1.html