Watermarking of image using DCT
2 views (last 30 days)
Show older comments
I have been trying to run this code but I am getting somekinds of errors which I am not able to figure it out.
close all;
clear all;
clc;
a = imread('poor.jpg');
a1 = rgb2gray(a);
b = imread('mask.jpg');
b1 = rgb2gray(b);
f1 = subplot(2,3,1);
imshow(a1);
title(f1,'Target Image');
f1 = subplot(2,3,2);
imshow(b1);
title(f1,'Watermark Image');
a = double(a);
trgt_dct1 = dct2(a);
trgt_dct2 = trgt_dct1;
% temp = trgt_dct1;
mark_dct = dct2(b);
g = 10; %%%strength of watermark for invisible
opacity = 0.5; %%% for visible watermark
cm = 512;
rm = 512;
b = double(b);
g = double(g);
b = b/255;
trgt_dct1 = trgt_dct1 + g*b;
trgt_dct2 = trgt_dct2 + opacity*mark_dct;
f1 = subplot(2,3,3);
imshow(trgt_dct1);
title(f1,'Target Image DCT-1');
final_img1 = idct2(trgt_dct1)/255;
f1 = subplot(2,3,4);
imshow(trgt_dct2);
title(f1,'Target Image DCT-2');
final_img2 = idct2(trgt_dct2)/255;
f1 = subplot(2,3,5);
[peaksnr, snr] = psnr(final_img1,a);
% figure('Name','Invisible Watermarked Image output','NumberTitle','off');
imshow(final_img1);
title(f1,'Invisible Watermarked Image output');
xlabel(f1,['PSNR = ',peaksnr]);
% figure('Name','Visible Watermarked Image output','NumberTitle','off');
f1 = subplot(2,3,6);
imshow(final_img2);
title(f1,'Visible Watermarked Image output');
And it gived me following error:
Error using rgb2gray>parse_inputs (line 77)
MAP must be a m x 3 array.
Error in rgb2gray (line 52)
[X, threeD] = parse_inputs(X);
Error in diiippp1 (line 5)
a1 = rgb2gray(a);
I cannot find the problem and fix it. If somebody knows, please help me.Thanks!
1 Comment
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!