السلام عليكم ورحمة الله
ابغى منكم مساعدتي بهذا الكود
المشكله عندي في كود تقسيم الصوره هينا عندي بس يعرض لي اخر كود عمله
انا ابغاه يعرض لي اي كود احدده و اطلبه منه يعني مثلا لما اقول له اعرض لي البلوك 64 او اي بلوك ثاني يعرضه لي
ومشكوورين
%read the orgenal image and resize to 512*512
w=imread('bkg12fe0.jpg');
w=imresize(w,[512 512]);
k=size(w);
figure(1)
imshow(w)
title('Origianl image')
%convert the RGB to grat
a=rgb2gray(w);
figure(2)
imshow(a)
title('gray image')
% Dividing into 8x8 blocks
[r c]=size(a)
x=8;
count=0;
for i=1:x:r
for j=1:x:c
%get one block
block=double(a(i:1:min(i+7,c),j:1:min(j+7,r)));
count=count+(r/x);
j=dct2(block);
end
end
figure(3)
imshow(j)
% The discrete cosine transform
j=dct2(block);
figure(4)
imshow(j)
%The encoding
for i=1:k
Bi=dct2(j);
mi=0;
if Bi(1,1)>Bi(1,8);
temp=Bi(1,1);
Bi(1,1)=Bi(1,8);
Bi(1,8)=temp;
end
%else
if Bi(1,1)<Bi(1,8);
temp=Bi(1,1);
Bi(1,1)=Bi(1,8);
Bi(1,8)=temp;
end
end
for i=1:x:r
for j=1:x:c
%get one block
block=double(a(i:1:min(i+7,c),j:1:min(j+7,r)));
count=count+(r/x);
j=dct2(block(;
end
end
غيري الكود السابق ليكن كالتالي
ttt=1;
for i=1:x:r
for j=1:x:c
%get one block
block(:,:,ttt)=double(a(i:1:min(i+7,c),j:1:min(j+7,r)));
count=count+(r/x);
j=dct2(block(:,:,ttt));
ttt=ttt+1;
end
end
%read the orgenal image and resize to 512*512
w=imread('bkg12fe0.jpg');
w=imresize(w,[512 512]);
k=size(w);
figure(1)
imshow(w)
title('Origianl image')
%convert the RGB to grat
a=rgb2gray(w);
figure(2)
imshow(a)
title('gray image')
% Dividing into 8x8 blocks
[r c]=size(a)
x=8;
count=0;
ttt=1;
for i=1:x:r
for j=1:x:c
%get one block
block(:,:,ttt)=double(a(i:1:min(i+7,c),j:1:min(j+7,r)));
count=count+(r/x);
j=dct2(block(:,:,ttt));
ttt=ttt+1;
j(:,:,ttt)=dct2(block(:,:,ttt));
end
end
figure(3)
imshow(j)
% The discrete cosine transform
n(:,:,ttt)=dct2(block(:,:,ttt));
figure(4)
imshow(n)
%The encoding
for i=1:k[/color]
Bi=dct2(j);
mi=0;
if Bi(1,1)>Bi(1,8);[/color]
temp=Bi(1,1);
Bi(1,1)=Bi(1,8);
Bi(1,8)=temp;
end
%else
if Bi(1,1)<Bi(1,8);
temp=Bi(1,1);
Bi(1,1)=Bi(1,8);
Bi(1,8)=temp;
end
end
هذا اللي طلع لي بالكومند ويندوز
r =
512
c =
512
??? Index exceeds matrix dimensions.
Error in ==> nada1 at 32
j(:,:,ttt)=dct2(block(:,:,ttt));
%read the orgenal image and resize to 512*512
w=imread('bkg12fe0.jpg');
w=imresize(w,[512 512]);
k=size(w);
figure(1)
imshow(w)
title('Origianl image')
%convert the RGB to grat
a=rgb2gray(w);
figure(2)
imshow(a)
title('gray image')
% Dividing into 8x8 blocks
[r c]=size(a)
x=8;
count=0;
ttt=1;
for i=1:x:r
for j=1:x:c
%get one block
block(:,:,ttt)=double(a(i:1:min(i+7,c),j:1:min(j+7,r)));
count=count+(r/x);
dct_of_block(:,:,ttt)=dct2(block(:,:,ttt));
ttt=ttt+1;
end
end
الكود اللي بعذ كذا هو خاطئ لنك يجب ان تحدد له البلوك أو الدي سي تي الذي تريد ان ترسمه في شكل 3 و 4
مثلا يمكن ان نختار الدي سي تي للبلوك العاشر
نكتب الاتي
صحيح الكود اللى نعمله له دي سي تي نعمله كونتزيشن
فالخطاء يكون من بعد الصوره االثالثه بالتالى لا تضهر الصوره الرابعه
لماذا احدد له رقم بلوك معين لماذا لايكون رقم البلوك كما فى البوكات السابقه
؟