MATLAB programavimas, padekit!

Jeigu programuojate ir norite ko nors paklausti ar pasidalinti patirtimi, darykite tai čia...
Post Reply
User avatar
jono_sankaba
Posts: 1
Joined: 2009-05-22 16:22
Location: Vilnius
Contact:

2009-05-23 11:50

Sveiki, tai va, darau vaizdo rekonstrukcija is fazes 1bito, amplitude prilyginęs konstantai, bet po 100 iteracijų paveiksliukas nesigauna pagrazejes, kazkas blogai, gal su ciklu, arba kazkaip kitaip su amplitude reikia ka daryt, jau nebesugalvoju, jei galit paziurekit ir pasakykit jei zinot kur cia problemos! ACIU! Kodas:

pav = imread('logo.jpg');
pav=rgb2gray(pav);
l=256;

[m,n]=size(pav);
len=m*n;
image2=reshape(pav,len,1);
h = hist(image2,[0:l-1]);
%h=imhist(pav);
save h;
xform=[
1 0 0
0 1 0
64 64 1];
tform_translate=maketform('affine',xform);
pav2 = imtransform(pav, tform_translate,...
'XData', [1 (size(pav,2)+xform(3,1))],...
'YData', [1 (size(pav,1)+xform(3,2))]);
figure, imshow(pav2)
pavfft=fft2(pav2);
phi=angle(pavfft);
ampl=abs(pavfft);
ampl(=4760;
phi(phi<0)=0;
phi(phi>0)=1;
save phi;
phi2=phi;
phi2(phi==0)=-pi/2;
phi2(phi==1)=pi/2;
ipav= ampl.*exp(phi2*sqrt(-1));
ipavfft=uint8(abs(ifft2(ipav)));
his_n=ipavfft(65:128,65:128);
his=histeq(his_n,h);
xform=[
1 0 0
0 1 0
64 64 1];
tform_translate=maketform('affine',xform);
his2 = imtransform(his, tform_translate,...
'XData', [1 (size(his,2)+xform(3,1))],...
'YData', [1 (size(his,1)+xform(3,2))]);
his3=his2;
figure, imshow(his2)
iter=0;
while iter<10
pavfft2=fft2(his3);
phi3=angle(pavfft2);
ampl(=5500;
[M,N] = size(phi3);
for i = 1:1:M,
for j = 1:1:N,
if phi3(i,j)>0 & phi(i,j)==0
phi3(i,j) = -pi/2 ; end
if phi3(i,j)<0 & phi(i,j)==1
phi3(i,j)=pi/2;end
end
end
ipavfft2=uint8(abs(ifft2(ampl.*exp(phi3*sqrt(-1)))));
his_n2=ipavfft2(65:128,65:128);
his2=histeq(his_n2,h);
xform=[
1 0 0
0 1 0
64 64 1];
tform_translate=maketform('affine',xform);
his3 = imtransform(his2, tform_translate,...
'XData', [1 (size(his2,2)+xform(3,1))],...
'YData', [1 (size(his2,1)+xform(3,2))]);
iter=iter+1;
end

figure, imshow(his3);

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest