hello experts.....please help me to solved out this error"Attempted to access Y(1,17); index out of bounds because size(Y)=[16,16]."

1 Ansicht (letzte 30 Tage)
close all;
clear;
[Y,map]=imread('lena256.bmp');
X=double(Y);
image(Y),colormap(map);
title('original image');
[h1,h2,g1,g2]=filtres2(7);
[x10000,x20000,x30000,x40000] = decomp_mat(X,'bior4.4');
[x1000,x2000,x3000,x4000] = decomp_mat(x10000,'bior4.4');
[x100,x200,x300,x400]= decomp_mat(x1000,'bior4.4');
[x10,x20,x30,x40]= decomp_mat(x100,'bior4.4');
[x1,x2,x3,x4]= decomp_mat(x10,'bior4.4');
[xx1,xx2,xx3,xx4]= decomp_mat(x1,'bior4.4');
[xxx1,xxx2,xxx3,xxx4]= decomp_mat(xx1,'bior4.4');
x1=round(x1); x2=round(x2); x3=round(x3); x4=round(x4);
xx1=round(xx1); xx2=round(xx2); xx3=round(xx3); xx4=round(xx4);
xxx1=round(xxx1); xxx2=round(xxx2); xxx3=round(xxx3); xxx4=round(xxx4);
seuil=max(max(xxx1))/2;
seuil=round(seuil); %39--
mm=max(max(xxx1)); %78
s=seuil;% s=39
q=s/2; %19.5000
XXX1=raff(xxx1,s,q,mm); XXX2=raff(xxx2,s,q,mm); XXX3=raff(xxx3,s,q,mm); XXX4=raff(xxx4,s,q,mm); XX2=raff(xx2,s,q,mm); XX3=raff(xx3,s,q,mm); XX4=raff(xx4,s,q,mm);
X2=raff(x2,s,q,mm); X3=raff(x3,s,q,mm); X4=raff(x4,s,q,mm);
XX1=reconst_mat(XXX1,XXX2,XXX3,XXX4,'bior4.4');XX1=XX1*2;
X1=reconst_mat(XX1,XX2,XX3,XX4,'bior4.4');X1=X1*2;
Y=reconst_mat(X1,X2,X3,X4,'bior4.4');
Y=double(Y);
figure(2),image(Y),colormap(map);
%-----------------------------------------------------------
function [h1,h2,g1,g2]=filtres2(b) %b=7
case 7 % case 7 is for bior4.4
%wave='bior2.2';
[hh1,hh2,gg1,gg2] = wfilters('bior4.4');
%wavmax=wmaxlev(dimention,wave);
[d1,d]=size(hh1);
for i=1:d % i=1 to 10
h1(i)=hh1(d-i+1);
h2(i)=hh2(d-i+1);
g1(i)=gg1(d-i+1);
g2(i)=gg2(d-i+1);
end
function [zz1,zz2,zz3,zz4]=decomp_mat(matx,filter)
[hh1,hh2,gg1,gg2] = wfilters(filter);
[d1,d]=size(hh1);
for i=1:d
h1(i)=hh1(d-i+1);
h2(i)=hh2(d-i+1);
g1(i)=gg1(d-i+1);
g2(i)=gg2(d-i+1);
end
[p1,p2]=size(matx);
[s1,s2]=size(h1);
m1=new_mat2(p1,p2,h1);
m2=new_mat2(p1,p2,h2);
y1=matx*m1;
y2=matx*m2;
k=1;
for i=1:2:p2
yy1(:,k)=y1(:,i);
yy2(:,k)=y2(:,i);
k=k+1;
end
clear m1 m2
m1=new_mat1(p1,p2,h1);
m2=new_mat1(p1,p2,h2);
z1=m1*yy1;
z2=m2*yy1;
z3=m1*yy2;
z4=m2*yy2;
k=1;
for i=1:2:p1
zz1(k,:)=z1(i,:);
zz2(k,:)=z2(i,:);
zz3(k,:)=z3(i,:);
zz4(k,:)=z4(i,:);
k=k+1;
end
zz1=zz1;
zz2=zz2;
zz3=zz3;
zz4=zz4;
function [mrx]=reconst_mat(zz1,zz2,zz3,zz4,filter)
%zz1=zz1*2;zz2=zz2*2;zz3=zz3*2;zz4=zz4*2;
[hh1,hh2,gg1,gg2] = wfilters(filter);
[d1,d]=size(hh1);
for i=1:d
h1(i)=hh1(d-i+1);
h2(i)=hh2(d-i+1);
g1(i)=gg1(d-i+1);
g2(i)=gg2(d-i+1);
end
[p1,p2]=size(zz1);
[s1,s2]=size(g1);
k=1;
for i=1:p1
z1(k,:)=zz1(i,:);z1(k+1,:)=0;
z2(k,:)=zz2(i,:);z2(k+1,:)=0;
z3(k,:)=zz3(i,:);z3(k+1,:)=0;
z4(k,:)=zz4(i,:);z4(k+1,:)=0;
k=k+2;
end
m1=mat1(p1*2,p2*2,g1);
m2=mat1(p1*2,p2*2,g2);
y1=m1*z1; y2=m2*z2; y3=m1*z3; y4=m2*z4;
yy1=y1+y2;
yy2=y3+y4;
clear y1 y2 y3 y4
k=1;
for i=1:p2
x1(:,k)=yy1(:,i);x1(:,k+1)=0;
x2(:,k)=yy2(:,i);x2(:,k+1)=0;
k=k+2;
end
clear m1 m2
m1=mat2(p1*2,p2*2,g1);
m2=mat2(p1*2,p2*2,g2);
y1=x1*m1;
y2=x2*m2;
mrx=y1+y2;
mrx=decalage(mrx,g1);
function [Y]=raff(Y,seuil,q,max)
[a,b]=size(Y);%a=2,b=2
for i=1:a %i=1:2
for j=1:b %j=1:2
s=seuil;% s=39
while s<=max
if (abs(Y(i,j))>=s)&(abs(Y(i,j))<=s+q)
if (Y(i,j)>0)
Y(i,j)=s+q/2;
else
Y(i,j)=-(s+q/2);
end
end
s=s+q;
end
if abs(Y(i,j))<seuil
Y(i,j)=0;
end
end
end

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by