igray is the image to be encrypted but not used in the algorithm
Show older comments
clc; clear all; imgname=input('Enter an image file name: ', 's'); irgb=imread(imgname);
[p,q,r]=size(irgb); m=1:p; n=1:q; ir=irgb(m,n,1); ig=irgb(m,n,2); ib=irgb(m,n,3); for m=1:p for n=1:q igray(m,n)=(0.2989*ir(m,n)+0.5870*ig(m,n)+0.1140*ib(m,n)); end end %rgb2gray(irgb)
igray=double(igray);
str=input('Enter a string: ','s'); str=double(str); len=size(str); strlen=len(1,2); k=rand([1,20],1);
m=1; n=1; str(strlen+1)=0; for i=1:strlen+1 g=str(i); a=zeros(1,7); for j=1:7 a(j)=rem(g,2); g=floor(g/2); %disp(g); if g==1 a(j+1)=rem(g,2); break end end %dec2bin(g) a; for j=1:7 if j==7 b(7)=a(1); else b(j)=a(j+1); end end %circshift(a,1,2);
for j=1:7
f=dec2bin(igray(m,n),8);
f=f-'0';
f(8)=b(j);
%disp(f);
m=m+1;
if m>p
n=n+1;
end
if n>q
display('String too long to fit');
end
end
end %disp(a); %disp(b); % for j=0:6 % str1(i)=str1(i)+b(j+1)*(2^j); % end % end %bin2dec(b) % % str1(1,1+strlen)=0; % for i=1:strlen+1 % Emb(1,i+1)=str1(1,i); % end % % m=1; % for j=1:k:p % for i=1:k:q % if(m>strlen+2) % break; % else % igray(i,j)=Emb(m); % m=m+1; % end % end % end %disp(Emb);
% igray matrix is being written into the gif image file but is not ussed in % the encryption algorithm. f matrix is used but it is not saved into an % external image file imwrite(igray,'abcd.gif'); imtool('abcd.gif');
Answers (1)
Image Analyst
on 6 May 2015
It looks to me like igray was used:
f=dec2bin(igray(m,n),8);
4 Comments
Anushree Bhatt
on 6 May 2015
Image Analyst
on 6 May 2015
Yeah, so? So use if you want to.
Anushree Bhatt
on 7 May 2015
Image Analyst
on 7 May 2015
We don't know how to answer you. Read this and then ask an actual question (a sentence that ends with a question mark), or at least explain what the "doubt" was so that some encryption expert might be able to answer you.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!