Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: i want to simplify this code
Replies: 14   Last Post: Apr 22, 2013 7:11 AM

 Messages: [ Previous | Next ]
 mohammed Posts: 18 From: egypt Registered: 12/10/07
Re: i want to simplify this code
Posted: Apr 7, 2013 5:18 PM

this is the full code

clear
I=imresize(I,[256 256]);
I=rgb2gray(I);
I = im2double(I);
S = qtdecomp(I,.40);
T2 = dctmtx(2);
T4 = dctmtx(4);
T8 = dctmtx(8);
T16 = dctmtx(16);
T32 = dctmtx(32);
T64 = dctmtx(64);
T0=dctmtx(1);

mask4 = [1 1 1 1
1 1 1 0
1 0 0 0
0 0 0 0 ];
1 1 ];
All= zeros(size(I));

[x2,y2,z2]=find(S==2);
for n2=1:length(x2)
B1=T2* I(x2(n2):x2(n2)+1,y2(n2):y2(n2)+1)* T2';
F1=T2'*R1*T2;
All(x2(n2):x2(n2)+1,y2(n2):y2(n2)+1)=F1;
end

[x4,y4,z4]=find(S==4);
for n4=1:length(x4)
B2=T4*I(x4(n4):x4(n4)+3,y4(n4):y4(n4)+3)*T4';
F2=T4'*R2*T4;
All(x4(n4):x4(n4)+3,y4(n4):y4(n4)+3)=F2;

end
[x8,y8,z8]=find(S==8);
for n8=1:length(x8)
B8=T8*I(x8(n8):x8(n8)+7,y8(n8):y8(n8)+7)*T8';
F8=T8'*R8*T8;
All(x8(n8):x8(n8)+7,y8(n8):y8(n8)+7)=F8;

end

[x0,y0,z0]=find(S==1);
for n=1:length(x0)
B0= T0 * I(x0(n),y0(n)) * T0';

All(x0(n),y0(n))=B0;
end

[x16,y16,z16]=find(S==16);
for n16=1:length(x16)
B3= T16 * I(x16(n16):x16(n16)+15,y16(n16):y16(n16)+15) * T16';
F4 = T16' * R4 * T16;
All(x16(n16):x16(n16)+15,y16(n16):y16(n16)+15)=F4;
end

[x32,y32,z32]=find(S==32);
for n32=1:length(x32)
B4= T32* I(x32(n32):x32(n32)+31,y32(n32):y32(n32)+31) * T32';
F5 = T32' * R5 * T32 ;
All(x32(n32):x32(n32)+31,y32(n32):y32(n32)+31)=F5;
end

[x64,y64,z64]=find(S==64);
for n64=1:length(x64)
B5=T64 * I(x64(n64):x64(n64)+63,y64(n64):y64(n64)+63) * T64';
F6= T64' * R6 * T64 ;

All(x64(n64):x64(n64)+63,y64(n64):y64(n64)+63)=F6;
end

imshow(I)

Date Subject Author
3/30/13 mohammed
4/6/13 mohammed
4/6/13 dpb
4/7/13 Bruno Luong
4/7/13 mohammed
4/7/13 mohammed
4/7/13 dpb
4/7/13 mohammed
4/7/13 dpb
4/7/13 mohammed
4/7/13 dpb
4/14/13 mohammed
4/22/13 Bruno Luong
4/22/13 Bruno Luong
4/7/13 mohammed