Embed gray image to color image

2 views (last 30 days)
Faradisa
Faradisa on 1 Feb 2018
Answered: Faradisa on 4 Feb 2018
I want to embed grayscale image to color image using DCT watermarking technique. this is my source code but I failed to insert the gray image. how to fix it?
%function of jpeg_scan
function out=jpeg_scan(N,M);
scan_order = zeros(N,M);
scan_order(1,1) = 1;
diag_down = 1; x = 1; y = 2;
for k = 2:N*M,
scan_order(x,y) = k;
if diag_down==1, y=y-1;x=x+1; end;
if diag_down==0, y=y+1;x=x-1; end;
if y>N, y=N; x=x+2; diag_down=1; end;
if x>M, x=M; y=y+2; diag_down=0; end;
if y<1, y=1; diag_down=0; end;
if x<1, x=1; diag_down=1; end;
end;
out=scan_order;
%host image
host=imread('Lena512.bmp');
yCbCr = rgb2ycbcr(host);
Y = double(yCbCr(:,:,1));
[xm,xn] = size(Y);
scan_order = jpeg_scan(xm,xn);
% call watermark image (grayscale image)
watermark = imread('logo.bmp');
Wm = ?????
%transform Y component of host image to DCT
Y_dct = dct2(Y);
temp = Y_dct(:);
zz_dct_koeff = temp;
zz_dct_koeff(scan_order(:)) = temp;
V = zz_dct_koeff(L+1:L+n);
V = V + a*abs(V).*Wm;
zz_dct_koeff(L+1:L+n) = V;
temp = zz_dct_koeff(scan_order(:));
Yx_dct = reshape(temp,xm,xn);
Yx = uint8(idct2(Yx_dct));
yCbCr(:,:,1) = Yx;
wtm = ycbcr2rgb(yCbCr);
imwrite(wtm,'watermarked_image.bmp','bmp')
figure(1);imshow(host);title('HostImage')
figure(2);imshow(wtm);title('WatermarkedImage')

Answers (1)

Faradisa
Faradisa on 4 Feb 2018
please help me

Community Treasure Hunt

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

Start Hunting!