Info

This question is closed. Reopen it to edit or answer.

Subscript indices must either be real positive integers or logicals error

1 view (last 30 days)
Im1=imread('lena256gray.bmp'); %%%%%%%%first image in which an another image will embedded
figure('name','Lena Image');
imshow(Im1);title('Input Image');
%%%%%%%%%%%%%%%%%Dividing the input image into 16X16 block size
%%%%%%%%%
[imm imn]=size(Im1); %%%%%%%%%%%%%%Size of the Im1 image
Sr=16; %%%%%%%%%%%%%%size of image which we have to divide the image
Lnum=(imm/Sr)*(imn/Sr);
ln=zeros(Lnum,Sr,Sr);
for i=1:imm/Sr
for j=1:imn/Sr
k=(i-1)*imn/Sr+j;
ln(k,:,:)=Im1((i-1)*Sr+1:i*Sr,(j-1)*Sr+1:j*Sr);
end
end
ldn=dctb(ln); %%%%%%%%%function calling
%%%%%%%%%%%%%%%%%compression of lena image
%%%%%%%%%%%%%5
[nb sb]=size(ldn);
for n=1:nb
ldc(:,:,n)=ldn(n,1:4,1:4);
end
Ikey=randperm(4);
for n=1:nb
for r=1:4
ldr(:,r,n)=ldc(:,Ikey(r),n);
end
end
k=1;
A=[];
%for n=1:nb
%lde(:,:,n)=ln(n,1:4,1:4);
%end
for i=1:imm/Sr
ci=[];
for j=1:imn/Sr
ci=[ ci ldr(:,:,k)];
k=k+1;
end
A=[A;ci];
end
Aa=A;
figure('name','Compressed image');imshow(uint8(Aa));title('The Compressed output of lena image');
Aa=imresize(Aa,[12 12]);
imwrite(Aa,'tiny.bmp'); % This is a image of compressed lena images
%%%%%%%%%%%%%%%%%%%%%%%%%
Im2=imread('Megastar.bmp');figure('name','Cover image');
imshow(Im2); title('The Random image');
[imm imn]=size(Im2);
Lnum=(imm/Sr)*(imn/Sr);
ln1=zeros(Lnum,Sr,Sr);
for i=1:imm/Sr
for j=1:imn/Sr
k=(i-1)*imn/Sr+j;
ln1(k,:,:)=Im2((i-1)*Sr+1:i*Sr,(j-1)*Sr+1:j*Sr);
end
end
%%%%%%%%%applying dct to blocks divided %%%%%%%%%
%ldn1=dctb(ln1);
[nb1 sb1]=size(ln1);
for n=1:nb1%compression
ldc1(:,:,n)=ln1(n,1:4,1:4);
end
k1=1;
B=[];
for i=1:imm/Sr
ci1=[];
for j=1:imn/Sr
ci1=[ ci1 ldc1(:,:,k1)];
k1=k1+1;
end
B=[B;ci1];
end
figure('name','Compressed Image');imshow(uint8(B));title('Compressed image of Random Image');
imwrite(uint8(B),'compressedcover.bmp');
[row col]=size(Aa);% size(B)
C=zeros(row,col);
for p=1:row
for q=1:col
C(p,q)=Aa(p,q)+B(p,q);
end
end
%figure('name',' output');imshow(uint8(C));title('The final output figure');
save dummy.mat I*;
hide_image('compressedcover.bmp','tiny.bmp');
TOI=imread('compressedcover.bmp');
%%%%%%%%%to show the final transmitter output in figure window write the
%%%%%%%%%below in Command window;
%%%%%%%%%%figure;imshow(TOI); title('The TxOutput');

Answers (0)

Community Treasure Hunt

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

Start Hunting!