i am trying to watermark image lets say of size 32 * 32 to host image of size 256*256 using simple svd algorithm by modifying singular values of S matrix开发者_Go百科.but nt able to watermark a smaller size image to host image,if someone help with coding thn i ll be grateful
I was about to leave a comment but it grew bigger so I post it as an answer even if the question is still vague.
As Amro said, you should post your current code and detail precisely what is not working (with relevant error messages for instance).
Without these precisions one can only guess what your problem is.
There is a post on Matlab Central that details a procedure to watermark an image using SVD.
I guess your problem is that your watermark image is smaller than your target image so you ran into "dimensions mismatch" errors somewhere. One solution is to pad you watermark image to fit the target image (see this question).
It seems to work on my computer with this quick try.
% Image
Himg=100;
Wimg=100;
img=imread('stackoverflow.png');
img=imresize(img,[Himg Wimg]);
img=im2double(img);
for i=1:3
[Uimg(:,:,i) Simg(:,:,i) Vimg(:,:,i)]=svd(img(:,:,i));
end
% Watermark
wat=imread('stackoverflow_logo.png');
Hwat=30;
Wwat=30;
wat=imresize(wat,[Hwat Wwat]);
wat=im2double(wat);
% Padding
wat=padarray(wat,[floor((Himg-Hwat)/2) floor((Wimg-Wwat)/2)], 'replicate','post');
wat=padarray(wat,[ceil((Himg-Hwat)/2) ceil((Wimg-Wwat)/2)], 'replicate','pre');
% Result
alpha=0.2;
Simg=Simg+alpha*wat;
for i=1:3
[Ures(:,:,i) Sres(:,:,i) Vres(:,:,i)]=svd(Simg(:,:,i));
res(:,:,i)=Uimg(:,:,i)*Sres(:,:,i)*Vimg(:,:,i)';
end
figure;
imshow(img);
figure;
imshow(wat);
figure;
imshow(res);
You can use a simple spatial domain, bit-planes watermarking, and do some resizing before and after for the watermark.
精彩评论