Finding linear chirp parameters from a low quality spectrogram, possibly with image processing techniques? tl;dr: What is a fast way to get the equation of this line?

I have to extract the "line of best fit" from this data (shown below), and many others like it (so I need a robust method). It is a a spectrogram of a linear chirp. The x axis is frequency and the y-axis is time. The linear chirp came from a truck outputting 4-140Hz linearly over exactly 8 seconds, but attenuation in the ground and some other physical phenomena mean that we are seeing a signal for around 10 seconds.

I looked into using the Hough transform to find the gradient of the line, and then cross-correlating the data with a line of this gradient. But the Hough transform is too slow to perform en mass, which is what I need to do.

I thought about finding the maxima for frequency ranges (5-10, 10-15, etc.) and plotting a line of best fit through these, but in this particular example there are only two or three areas of strong intensity.

The other spectrograms look like this but the high intensity regions will move around to different points on the line, and some may have more noise.

Whats a good way of doing this algorithmically?

My current idea is:


Look for highest intesity regions.
Look at many pixels in their neighbourhood and estimate the "center of mass".
Draw line between them and find equation of line.


Is there a better way?
I think you can use standart method of fitting data to Straight Line. See for example explanation in 15.2 of "Numerical Recipes in C" http://apps.nrbook.com/c/index.html (page 661-662)


To prepare arrays of $x_i$, $y_i$, $\sigma_i$, you must for each point on your image (frequency-time):
$x_i$ := frequency
$y_i$ := time
$\sigma_i$ := 1/intensity (or 1/intensity$^2$)
size of arrays will be N*M (N, M - x and y size of spectrogram in points)
Calculate a and  b (y = a + b*x) by using formula (15.2.6) from http://apps.nrbook.com/c/index.html
If it will be some problem with outliers, use some robust fitting method. See for example 15.7 of  http://apps.nrbook.com/c/index.html. But I think there will not such problem with your data.


This method is faster then Hough transform

EDIT
It is very important to choose good expression for $\sigma_i$. May be better results will be with $\sigma_i$ := $1/\sqrt{intensity}$. May be will be better to use $\sigma_i$ := 1/(intensity-background) for (intensity > background) and exclude all points with (intensity &lt; background). If there are some limitations on parameres of straight line (a,b), you can exclude some x-y points from $x_i$-$y_i$ arrays. But this modifications depend on actual data. It will be very interesting to see the your results.