1

I recently came across the fact, following this question, that we can use spectral coherence to find the similarity between two fourier transforms. Now, I have two contours, which I have obtained by applying Canny edge detection on two images. I was wondering if I can model the contours as data points i.e. (x,y) coordinates, and apply DFT on them, and whether I can use the spectral coherence to measure the similarity between the two contours. Here are the two contours, as reference.

enter image description here enter image description here

It should be noted that the contours are slightly different, although they might seem to be the same. Thanks in advance.

Sudipto
  • 11
  • 2
  • You could, but it begs a deeper question: why are you doing this? What aspect of reality is supposed to be reflected by this "similarity"? Since you have contours, likely you are comparing them in order to compare the functions they are contouring. That would suggest a very different measure of "similarity" than the one you propose (which would work well in other circumstances, such as comparing general features on related maps). Thus additional information about the context of your work and its objectives would be very useful. – whuber Jan 20 '15 at 15:45
  • Thanks for the comment. Actually, I am working on pose estimation. So I need to align a source contour to a target contour, iteratively, minimizing the difference between the two shapes. Thus, I was thinking, maybe I could use the coordinates of the contour pixels as data points, and treat them as a time series. My question was, whether I could use the concept of coherence to measure the similarity between the two. – Sudipto Jan 20 '15 at 16:09
  • It's starting to sound like your "contour" may be the boundary of a region extracted from an image according to certain criteria. If that's correct, then you want to be comparing two (discretized and perhaps smoothed) *regions* -- which is not quite the same thing as comparing their boundaries. It's best to be clear and forthcoming about what kind of data you are actually working with so that subtleties like that are not lost in the asking of the question. – whuber Jan 20 '15 at 16:14
  • Thanks @whuber, I have edited the question, and have also added two images, so that it becomes a little bit clear. And yeah, you are right. By contour, I meant boundary of a region in an image. – Sudipto Jan 20 '15 at 19:22
  • Yes you can. I did this long time ago. Check out this paper first http://knight.temple.edu/~lakamper/courses/cis9601_2009/etc/fourierShape.pdf However fourier descriptors are not the best performers. Curvature Scale Space had better success. Your counters are also not continuous so it may be a problem for complex coordinates approach. – Cagdas Ozgenc Jan 20 '15 at 19:24
  • Thanks @CagdasOzgenc. So if I take the weighted sum of the coherences of frequencies that are dominant, higher the sum, the more similar they are. Right ? – Sudipto Jan 20 '15 at 19:26
  • Thanks a lot @CagdasOzgenc. :) Are the codes for this paper available ? – Sudipto Jan 20 '15 at 19:28
  • When you look at the FFT of complex coordinates you will see that you need only the lower frequencies as the high frequencies correspond to small irregularities. You simply take the magnitude of n-lower frequencies and compare for example with sum of squared distance of each component. You may equally weight them. But check out Curvature Scale Space. http://www.image.ece.ntua.gr/courses_static/dip/advanced/material/retrieval/Curvature%20scale%20space%20image%20in%20shape%20similarity%20retrieval.pdf It is known to work better for contours. – Cagdas Ozgenc Jan 20 '15 at 19:29
  • Seems like if I take the n-lower frequencies, then I don't need to use spectral coherence. But I'll give the curvature scale space a try. – Sudipto Jan 20 '15 at 19:35
  • In my experiments I didn't have holes in the contours and they were single loops. When you are taking the FFT you take one tour around the contour with equal arc-length steps. I don't know how you will deal with wholes (handle) and multiple loops (body and cap). – Cagdas Ozgenc Jan 20 '15 at 19:39
  • Yeah, so I guess curvature scale space is the only option. Anyway, thanks for the comments. I had been trying to use FFT, when it turns out that it won't work with holes in contours. Thanks man :) – Sudipto Jan 20 '15 at 19:43

0 Answers0