File Exchange

image thumbnail

Elliptical Fourier shape descriptors

version 1.0 (3.66 KB) by

Forward and reverse elliptical Fourier transforms of x,y data

4.38462
13 Ratings

17 Downloads

Updated

View License

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.

Comments and Ratings (14)

Simon Dixon

Good work

My rating is based on the function using the correction by Sungeun Eom below. The function is used in this scientific paper whose approach can be reverse engineered to see how the input files should look etc.
Costa, C., et al. (2011). "Shape Analysis of Agricultural Products: A Review of Recent Research Advances and Potential Application to Computer Vision." Food and Bioprocess Technology 4(5): 673-692.

I have also struggled with the normalisation functions and had to disable these to get meaningful results and to get the rEfourier script to work.

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.

Thomas

Thomas (view profile)

Have used the code and it seems to produce very nice results. Have applied the corrections mentioned by Sungeun Eom.

can we have some example how to use this code ?

sanqin zhao

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.

Abdul Rana

Is it posssible for you to upload a detailed help description along with this file?

Xiaoming Liu

Very good, easy to use. one question, if I need to use it as features, how to organize the 4 coefficients?

YOUSHIA youshbob

YYOOUU SSSSSSSSTTTTTTTIINNNKKKKKKKKKKK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Sungeun Eom

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:

1) rTheta1 (line 137-138)
rTheta1 = 0.5 * atan(2 * (rFSDsTemp(1,2) * rFSDsTemp(2,2) + rFSDsTemp(3,2) * rFSDsTemp(4,2)) / ...
        (rFSDsTemp(1,2)^2 + rFSDsTemp(3,2)^2 - rFSDsTemp(2,2)^2 - rFSDsTemp(4,2)^2));
    rTheta2 = 0.5 * (pi + atan(2 * (rFSDsTemp(1,2) * rFSDsTemp(2,2) + rFSDsTemp(3,2) * rFSDsTemp(4,2)) / ...
        (rFSDsTemp(1,2)^2 + rFSDsTemp(3,2)^2 - rFSDsTemp(2,2)^2 - rFSDsTemp(4,2)^2)) );
    x11 = rFSDsTemp(1,2)*cos(rTheta1) + rFSDsTemp(2,2)*sin(rTheta1);
    y11 = rFSDsTemp(3,2)*cos(rTheta1) + rFSDsTemp(4,2)*sin(rTheta1);
    axisDist1 = x11^2 + y11^2;
    x22 = rFSDsTemp(1,2)*cos(rTheta2) + rFSDsTemp(2,2)*sin(rTheta2);
    y22 = rFSDsTemp(3,2)*cos(rTheta2) + rFSDsTemp(4,2)*sin(rTheta2);
    axisDist2 = x22^2 + y22^2;
    if (axisDist2 > axisDist1)
        rTheta1 = rTheta2;
    end

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

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?

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.

Vidyaangi Patil

praveen kumar

MATLAB Release
MATLAB 7.2 (R2006a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video