Compare two images[Binary] using moment and fourier descriptor
1 view (last 30 days)
Show older comments
- Hi
- I have some Binary images with the same size .
- what can I do to compare two images(same size) with moment and fourier descriptor?
- I've already searched in the internet but I found nothing useful about that.
- anyone can explain what should I do?
- Are there any Toolbox in matlab to help me?
- I found the functions that calculate moment and Fourier Descriptor but I don't know how I use them.
function outmom = raw_moments(im,i,j)
outmom = sum(sum( ((1:size(im,1))'.^j * (1:size(im,2)).^i) .* im ));
end
function cmom = central_moments(im,i,j)
rawm00 = raw_moments(im,0,0);
centroids = [raw_moments(im,1,0)/rawm00 , raw_moments(im,0,1)/rawm00];
cmom = sum(sum( (([1:size(im,1)]-centroids(2))'.^j * ...
([1:size(im,2)]-centroids(1)).^i) .* im ));
end
.................
function z = frdescp(s)
%FRDESCP Computes Fourier descriptors.
% Z = FRDESCP(S) computes the Fourier descriptors of S, which is an
% np-by-2 sequence of image coordinates describing a boundary.
%
% Due to symmetry considerations when working with inverse Fourier
% descriptors based on fewer than np terms, the number of points in
% S when computing the descriptors must be even. If the number of
% points is odd, FRDESCP duplicates the end point and adds it at
% the end of the sequence. If a different treatment is desired, the
% sequence must be processed externally so that it has an even
% number of points.
%
% See function IFRDESCP for computing the inverse descriptors.
% Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
% Digital Image Processing Using MATLAB, Prentice-Hall, 2004
% $Revision: 1.4 $ $Date: 2003/10/26 23:13:28 $
% Preliminaries
[np, nc] = size(s);
if nc ~= 2
error('S must be of size np-by-2.');
end
if np/2 ~= round(np/2);
s(end + 1, :) = s(end, :);
np = np + 1;
end
% Create an alternating sequence of 1s and -1s for use in centering
% the transform.
x = 0:(np - 1);
m = ((-1) .^ x)';
% Multiply the input sequence by alternating 1s and -1s to
% center the transform.
s(:, 1) = m .* s(:, 1);
s(:, 2) = m .* s(:, 2);
% Convert coordinates to complex numbers.
s = s(:, 1) + i*s(:, 2);
% Compute the descriptors.
z = fft(s);
Thank you for your Answer
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!