These two functions impliment the system of elliptical Fourier shape descriptors first described by Kuhl and Giardina in "Elliptic Fourier features of a closed contour" Computer Graphics and Image Processing 18:236-258 1982. fEfourier is the forward transform which creates a "shape spectrum" of a closed x,y outline, rEfourier takes a specified number of harmonics from the spectrum and reconstructs the x,y outline. The functions are not only useful for the creation of shape descriptors but also for smoothing outlines or reducing an arbitrary outline to a specified number of points.
I assume that the input outline to these functions is an array of (x,y) coordinates and not a chain code as is described in the Kuhl... paper originally. Is that correct. An other thing does the outline need to be continues link of pixels or can it be a link of vectors?
This is great work and nice of you to share it with us.
Excellent codes. I have also found the same problem that You didn't check whether it is a semimajor or semiminor axis.Meanwhile, the code can use the vectorization to speed up.For example, 'rDeltaX = diff(b(:,1)); rDeltaY = diff(b(:,2));' can replace the for loop.
Thanks for your work, but I have found two bugs in calculating rTheta1 and rPsi1. You didn't check whether it is a semimajor or semiminor axis. This is one fix for the problem for your information:
2) rPsi1 (line 148)
if (rStarFSDs(3,2)~=0)
if (rStarFSDs(1,2)>=0)
rPsi1 = atan(rStarFSDs(3,2) / rStarFSDs(1,2));
else
rPsi1 = atan(rStarFSDs(3,2) / rStarFSDs(1,2)) + pi;
end
else
if (rStarFSDs(1,2)>0)
rPsi1 = atan(rStarFSDs(3,2) / rStarFSDs(1,2));
else
rPsi1 = atan(rStarFSDs(3,2) / rStarFSDs(1,2)) + pi;
end
end
07 Dec 2007
Trevor Beugeling
The algorithm works great. However, I am having some difficulties using the normalization options. If I enable either the size or orientation normalization (or both), the data returned after using the rEfourier function is not correct. Is there some extra processing that is required when converting normalized descriptors back into a closed contour?
28 Sep 2007
Graeme Penney
Overall excellent, though I suspect there may be a bug. I get much more sensible results if I omit the -1 from line 39 of fEfourier.m
iNoOfPoints = size(rDeltaT,1) - 1.