| century2010@gmail.com 2007-01-11, 3:56 am |
| Dear prof.
I am M. Nasiri, MSc graguated of Electronic. I have been working on
fractal image compression for two months. After study some papers, I
decided to write code for fractal encoding and decoding. I don't know
but perhaps I've made a mistake, Because the code wasn't work
correctly. I read several papers but I couldn't solve the problem.
Please help me.
In this code I considered some rules:
1- It is selected 's' for scale factor s=0.25, 0.5, 0.75, 1.
2- In search process, there is not overlap between Domain block due to
simplicity.
3- I used R=R_Av - s (Domain_hat - Domain_hat_AV) for
reconstruction process, that Domain_hat is properly domain block for
compairing domain block and AV means Average for any blocks.
I run the matlab code but in iteration step I don't have converge
picture. I have just one picture which isn't change.
I was wondering if you could run my code and say me my problem. I
attached my code with this Email.
Sincerely, Nasiri
clc
clear
ty = clock;
C=double((imread('c:\cameraman.tif')));
C=imcrop(C,[119 110 63 63]);
D=C;
Range=C;
Domain=D;
[M N]=size(C);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Domain_Hat Block
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
display('Please wait for less than a minute,until iii=32');
ii=1;
jj=1;
for k=0:((M/2)-1),
jj=1;
for h=0:((N/2)-1),
Domain_hat(ii,jj)=0. 25*sum(sum(Range(2*k+1:2*k+2,2*h+1:2*h+2
)));
jj=jj+1;
end
ii=ii+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%
%%%%%%%%%%%%%%%%%%%%% Average Calculation for Domain and Range
%%%%%%%%%%%%%%%%%%%%
ii=1;
jj=1;
for k=0:((M/2)-1),
jj=1;
for h=0:((N/2)-1),
Range_AV(ii,jj)=0. 25*sum(sum(Range(2*k+1:2*k+2,2*h+1:2*h+2
)));
jj=jj+1;
end
ii=ii+1;
end
ii=1;
jj=1;
for k=0:((M/4)-1),
jj=1;
for h=0:((N/4)-1),
Domain_hat_AV(ii,jj)=0. 25*sum(sum(Domain_hat(2*k+1:2*k+2,2*h+1:
2*h+2)));
jj=jj+1;
end
ii=ii+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%% Search %%%%%%%%%%%%%%%%%%%%%%%%%%%%
kk=0;
hh=0;
jjj=1;
iii=1
counter1=zeros(N/2);
for kk=0:((M/2)-1),
jjj=1;
for hh=0:((N/2)-1),
for ss=0.25:0.25:1,
ii=1;
jj=1;
for k=0:((M/4)-1),
jj=1;
for h=0:((N/4)-1),
diff(k+1,h+1,ss*4)=sum(sum(abs( Range(2*kk+1:2*kk+2,2*hh+1:2*hh+2)...
-Range_AV(iii,jjj)- ss*Domain_hat(2*k+1:2*k+2,2*h+1:2*h+2)+s
s*Domain_hat_AV(ii,jj))
));
jj=jj+1;
end
ii=ii+1;
end
end
[nn ekk]=min(min(min(diff)));
nn;
[rt yu]=min((diff(:,:,ekk)));
[ee1 rr1]=min(rt);
ee2=yu(rr1);
ss1(iii,jjj)=ekk;
y1(iii,jjj)=ee2;
x1(iii,jjj)=rr1;
x11=ee2;
y11=rr1;
counter1(x11,y11)=counter1(x11,y11)+1;
jjj=jjj+1;
end
iii=iii+1
end
%%%%%%%%%%%%%%%%%%%%%%% Reconstrunction
Process%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Range2=zeros(64);%%%%%% initial imge for reconstructing
for i=1:64,
for j=1:64,
Range2(i,j)=j*3;
end
end
ii=1;
jj=1;
for k=0:((M/2)-1),
jj=1;
for h=0:((N/2)-1),
Range_AV2(ii,jj)=0. 25*sum(sum(Range2(2*k+1:2*k+2,2*h+1:2*h+
2)));
jj=jj+1;
end
ii=ii+1;
end
Domain_hat2=Range_AV2;
ii=1;
jj=1;
for k=0:((M/4)-1),
jj=1;
for h=0:((N/4)-1),
Domain_hat_AV2(ii,jj)=0. 25*sum(sum(Domain_hat2(2*k+1:2*k+2,2*h+1
:2*h+2)));
jj=jj+1;
end
ii=ii+1;
end
ii=0;
jj=0;
k=0;
h=0;
for k=0:((M/2)-1),
for h=0:((N/2)-1),
k1=x1(k+1,h+1)-1;
h1=y1(k+1,h+1)-1;
Rreconstructed_Image(2*k+1:2*k+2,2*h+1:2
*h+2)=((ss1(k+1,h+1)/4)*...
(Domain_hat2(2*k1+1:2*k1+2,2*h1+1:2*h1+2
)- Domain_hat_AV2(k1+1,h1+1)))+Range_AV2(k+
1,h+1);
end
end
subplot(224);
imshow(Rreconstructed_Image,[]);title('T
he ReConstructed Image ');
subplot(222);
imshow(Range2,[]);title('The Iteration Function ');
subplot(223);
imshow(Domain_hat,[]);title('The Domain Hat Image ');
subplot(221);
imshow(Range,[]);title('The Range Image ');
pause(1)
a111=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ITERATIVE PROCESS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
for iteration=1:8,
Range3=Rreconstructed_Image;
ii=1;
jj=1;
for k=0:((M/2)-1),
jj=1;
for h=0:((N/2)-1),
Range_AV1(ii,jj)=0. 25*sum(sum(Range3(2*k+1:2*k+2,2*h+1:2*h+
2)));
jj=jj+1;
end
ii=ii+1;
end
Domain_hat1=Range_AV1;
ii=1;
jj=1;
for k=0:((M/4)-1),
jj=1;
for h=0:((N/4)-1),
Domain_hat_AV1(ii,jj)=0. 25*sum(sum(Domain_hat1(2*k+1:2*k+2,2*h+1
:2*h+2)));
jj=jj+1;
end
ii=ii+1;
end
for k=0:((M/2)-1),
for h=0:((N/2)-1),
k1=x1(k+1,h+1)-1;
h1=y1(k+1,h+1)-1;
Rreconstructed_Image(2*k+1:2*k+2,2*h+1:2
*h+2)=((ss1(k+1,h+1)/4)*...
(Domain_hat1(2*k1+1:2*k1+2,2*h1+1:2*h1+2
)- Domain_hat_AV1(k1+1,h1+1)))+Range_AV1(k+
1,h+1);
end
end
pause(0.05)
subplot(224);
imshow(Rreconstructed_Image,[]);title('T
he ReConstructed Image ');
subplot(222);
imshow(Range2,[]);title('The Iteration Function ');
subplot(223);
imshow(Domain_hat,[]);title('The Domain Hat Image ');
subplot(221);
imshow(C,[]);title('The Range Image ');
end
|