extend the maatlab code for finding the shape of an image using HU moments for the entire database
2 views (last 30 days)
Show older comments
this is the code for single image i need it for the entire database i am not getting it please hep me if true
clc;
clear all;
close all;
A=double(imread('E:\matlab results\prgs i done\Wang database\1.jpg'));
[m,n]=size(A);
moo=sum(sum(A));
moo1=sum(moo);
m1o=0;
mo1=0;
for x=0:m-1
for y=0:n-1
m1o=m1o+(x)*A(x+1,y+1);
mo1=mo1+(y)*A(x+1,y+1);
end
end
xx=m1o/moo1;
yy=mo1/moo1;
mu_oo=moo;
mu=0;
for ii=0:m-1
x=ii-xx;
for jj=0:n-1
y=jj-yy;
mu=mu+(x)^2*(y)^0*A(ii+1,jj+1);
end
end
gamma=0.5*(2+0)+1;
nu=mu/moo1.^(gamma);
end
0 Comments
Answers (1)
Image Analyst
on 15 Mar 2015
I'm going to assume your "entire database" is just a bunch of image files in some folder. So then, to processes a sequence of files, see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
2 Comments
Image Analyst
on 16 Mar 2015
Of course it will. Why wouldn't it? Just place your code for computing moments into the center of the loop so that it operates on each image.
See Also
Categories
Find more on Convert Image Type 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!