# Comparing Images in MATLAB

Discussion in 'Programmer's Corner' started by Tek_Knowledge, Apr 23, 2008.

1. ### Tek_Knowledge Thread Starter New Member

Apr 23, 2008
6
0
Hi,
I'm basically developing an algorithm to compare/contrast music genres in MATLAB thru spectral analysis. Is there any way to compare the spectrograms of respective genres read in for similarity? Just give me a hint in the right direction.

Thanks

2. ### Dave Retired Moderator

Nov 17, 2003
6,960
144
The details are a little vague so I can't give a definitive answer. The first thing that springs to mind is to look into autocorrelation and matched filtering. These are typically time-domain approaches, and you are looking at spectral (frequency domain) approaches right?

Dave

3. ### Tek_Knowledge Thread Starter New Member

Apr 23, 2008
6
0

correct. Basically to add a little more detail, there are clear differences by the musical genres under analysis (jazz, hip hop, rock, classical) just by LOOKING at the spectrogram. the differences have to do with the frequency ranges they cover, and the amplitude (color intensity) at frequency levels. Hip-Hop and Rock are the most similar, with loud amplitudes covering nearly all frequencies but rock has a broader overall range in the spectrum. Would there be any algorithm i could implement to compare within and outside of genres to generate some type of meaningful result (i.e. a matching percentage?)

4. ### Dave Retired Moderator

Nov 17, 2003
6,960
144
Algorithms exist; look at the CLAM Framework as an example of research in progress.

As for doing this with your audio samples, then you need to look at something called Frame Clustering and Cluster Model Similarity (Aucouturier and Pachet are prominent names on this). Your frame is loudness per frequency range (do you describe it as frequency level - amplitude perhaps?), and it is a two step process from there; 1) Cluster the frames using a Gaussian Mixing Model, and 2) compute the similarities using one of the algorithms proposed in the literature: Earth Movers Distance and more recently Monte Carlo sampling (each has there benefits - EMD is faster, whereas MC tends to be more accurate).

It might be easier to represent the spectral data as Spectral Histograms - IIRC functions exist in Matlab to do this directly, if not head over to Matlab File Exchange.

I know this does not give you directly the answer for implementing it in Matlab, but hopefully gives you a framework to go forward. I have come across an OS Matlab toolbox that implements many of these algorithms, I can try and dig it out if you like.

Dave

5. ### Tek_Knowledge Thread Starter New Member

Apr 23, 2008
6
0
thanx man, thats a BIG help. unfortunatly i'm kinda shady on GMM's...i'll try to read up on it...try to dig up the toolbox if you can tho, that would be much appreciated

6. ### Tek_Knowledge Thread Starter New Member

Apr 23, 2008
6
0
oh yeah, and for making histograms you need to only have real components, correct? so how would you erradicate the imaginary part of the FFT or STFT to build the histogram?

7. ### Dave Retired Moderator

Nov 17, 2003
6,960
144
I might have it at work, but I'm OOO at the moment. You can get it from the Austrian Institute of Artificial Intelligence - it was available at their old link but this has now changed, so I don't know what the situation is in terms of obtaining it. You might be advised to contact them via their webpage and ask them about obtaining their open-source Matlab toolbox that you have come across in published literature. Failing that, I might have another contact that may be of use, but try the AIAI route first.

Dave

8. ### Dave Retired Moderator

Nov 17, 2003
6,960
144
Use the function real on the FFT output matrix X.

Dave

Nov 17, 2003
6,960
144