We took a first look at the frequency contours in the last part of the previous chapter, and now we look at them more deeply, explaining how contours are calculated and used to compute song features. SAP2 calculate frequency contours by detecting zero crossings of the spectral derivatives. In order to reject artifact, we require that the contours passed a certain contrast threshold.
We use a dynamic threshold T calculated for each time window
ti and frequency fi as:

were T’ is a user defined threshold
Therefore, the detection threshold is weighted by the distance from the mean frequency (the gravity center of the frequencies) and by the width of the power spectrum.
A pixel in the time frequency space is define as contour if i) there is zero crossing between the neighboring pixels at any one of the 8 possible directions (see diagram above) and ii) both neighboring pixels (in the direction of the zero crossing) are larger than
T.