Please check.code doesnt run,

14 views (last 30 days)
Ash Ch
Ash Ch on 21 Apr 2015
clc clear all close all
I=imread('lenna1.jpg'); J=I;
%RGB Key storage
i=I(:,:,1); p=i; %DWT hocche [f b c d]= dwt2(i, 'haar'); a1=d; a=uint8(d); edge_b=edge(a,'sobel'); %key1 store hocche T1 = [zeros(1,11), ones(1,11)]; T1 = T1(randperm(2*11)); T2 = [zeros(1,31), ones(1,30)]; T2 = T2(randperm(61)); z= transpose([T1 1 1 1 1 0 T2]); z(23:27) %message
key = [0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 ];
key2= transpose(key);
z1=xor(z,key2);
height = size(a,1);
width = size(a,2);
k1=length(z);
for i=1:1:height-1
for j=1:1:width-1
if edge_b(i,j)==1
if k1>0
lsb=mod(a(i,j),2);
if (lsb == z1(k1))
a(i,j) = a(i,j);
else
if(lsb == 1)
a(i,j) = a(i,j) - 1;
else
a(i,j) = a(i,j) + 1;
end
end
k1=k1-1;
end
end
end
end
aa=idwt2(f,b,c,a, 'haar');
J(:,:,1)=aa;
%DISPLAY
imagesc(p);
title('Unchanged HH after dwt');
drawnow
pause
imagesc(aa);
title('HH with steganography');
drawnow
pause
imagesc(I);
title('Real lenna');
drawnow
pause
imagesc(J);
title('Steganography kora lenna');
drawnow
%Main KAJ in HSV P=rgb2new3(J); i=P(:,:,2); p=i; [f b c d]= dwt2(i, 'haar'); a1=d; a=uint8(d); edge_b=edge(a,'sobel'); imshow(edge_b); message = 'Hello Lenna' message = strtrim(message); m = length(message) * 8; AsciiCode = uint8(message); binaryString = transpose(dec2bin(AsciiCode,8)); bst = binaryString(:); N = length(bst); z = zeros(N,1); for k = 1:N if(bst(k) == '1') z(k) = 1; else z(k) = 0; end end height = size(a,1); width = size(a,2); k1=m; for i=1:1:height-1 for j=1:1:width-1 if edge_b(i,j)==1 if k1>0 lsb=mod(a(i,j),2); if (lsb == z1(k1)) a(i,j) = a(i,j); else if(lsb == 1) a(i,j) = a(i,j) - 1; else a(i,j) = a(i,j) + 1; end end k1=k1-1; end end end end aa=idwt2(f,b,c,a, 'haar'); P(:,:,1)=aa; %DISPLAY imshow(p); title('1'); drawnow pause imshow(aa); title('2'); drawnow pause imshow(I); title('3'); drawnow pause imshow(P); title('4'); drawnow imwrite(P,'Steglenna.jpg');
rgb2new3: function [h,s,v] = rgb2new(r,g,b) n=30; switch nargin case 1, if isa(r, 'uint8'), r = double(r) / 255; elseif isa(r, 'uint16') r = double(r) / 65535; end case 3, if isa(r, 'uint8'), r = double(r) / 255; elseif isa(r, 'uint16') r = double(r) / 65535; end
if isa(g, 'uint8'),
g = double(g) / 255;
elseif isa(g, 'uint16')
g = double(g) / 65535;
end
if isa(b, 'uint8'),
b = double(b) / 255;
elseif isa(b, 'uint16')
b = double(b) / 65535;
end
otherwise,
error('MATLAB:rgb2hsv:WrongInputNum', 'Wrong number of input arguments.');
end
threeD = (ndims(r)==3); % Determine if input includes a 3-D array
if threeD, g = r(:,:,2); b = r(:,:,3); r = r(:,:,1); siz = size(r); r = r(:); g = g(:); b = b(:); elseif nargin==1, g = r(:,2); b = r(:,3); r = r(:,1); siz = size(r); else if ~isequal(size(r),size(g),size(b)), error('MATLAB:rgb2hsv:InputSizeMismatch', 'R,G,B must all be the same size.'); end siz = size(r); r = r(:); g = g(:); b = b(:); end
v = max(max(r,g),b); h = zeros(size(v)); s = (n*v - min(min(r,g),b));
z = ~s; s = s + z; k = find(r == v); h(k) = (g(k) - b(k))./s(k); k = find(g == v); h(k) = n + (b(k) - r(k))./s(k); k = find(b == v); h(k) = n + (r(k) - g(k))./s(k); h = h/6; k = find(h < 0); h(k) = h(k) + 1; h=(~z).*h;
k = find(v); s(k) = (~z(k)).*s(k)./v(k); s(~v) = 0;
if nargout<=1, if (threeD nargin==3), h = reshape(h,siz); s = reshape(s,siz); v = reshape(v,siz); h=cat(3,h,s,v); else h=[h s v]; end else h = reshape(h,siz); s = reshape(s,siz); v = reshape(v,siz); end

Answers (0)

Categories

Find more on AI for Signals and Images in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!