Image Averaging-need help urgently

Status
Not open for further replies.

Yesubai Rubavathi

Newbie level 4
Joined
Sep 7, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,325
matlab image averaging

I want to read images fromdatabase & resiz to same size for all & then take average of it. i have two images int the database.

code is:


clc;
y='z:\project\database';
dirlist=dir;
s=size(dirlist);
for m=1:256
for n=1:256
avg(m,n)=0;
end
end
for m = 3 : s
x= imread(strcat(y,'\',dirlist(m).name));
a= imresize(x,[256 256]);
for i = 1:256
for j = i:256
avg(i,j)=avg(i,j)+a(i,j);
end
end
end
av=avg./m;
figure,imshow(av);


but it won't run.
output is not correct.

plz help me to run this program.
I am expecting your reply soon.


Thankyou.
 

matlab program for image averaging

At first it seems you made an error
for j = i:256 - should be replaced by for j = 1:256

Second, the good styly of Matlab programming is vector-matrix operations
You can remove a lot of your for loops causing program run much faster

clc;
y='z:\project\database';
dirlist=dir;
s=size(dirlist);
avg=zeros(256);
for m = 3 : s
x= imread(strcat(y,'\',dirlist(m).name));
a= imresize(x,[256 256]);
avg=avg+a;
end
av=avg./m;
figure,imshow(av);
 

hi !

Thankyou for revealing my mistake .but your code avg=avg + a doesn't run , it shows error message like

??? Error using ==> plus
Integers can only be combined with integers of the same class, or scalar doubles.

Error in ==> locate1 at 10
avg = avg + a;

plz tell me some other way to get average of images.
I am expecting your reply.
Thankyou.





Added after 6 minutes:


hi !

Thankyou for revealing my mistake .but your code avg=avg + a doesn't run , it shows error message like

??? Error using ==> plus
Integers can only be combined with integers of the same class, or scalar doubles.

Error in ==> locate1 at 10
avg = avg + a;

plz tell me some other way to get average of images.
I am expecting your reply.
Thankyou.




 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…