You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
code for different attacks on watermarking
7 views (last 30 days)
Show older comments
please help for different types of attacks for watermarking
Answers (1)
Image Analyst
on 23 Apr 2022
See section 24.3 here:
You'll find lots of papers on it.
(Anticipating your next question.....)
Sorry, I don't have any of them coded up for you.
19 Comments
Sunita Pradhan
on 23 Apr 2022
i want the code for different geometric attacks on watermarking.please help me.am unable to change the code.please check the file and modify it for cropping and scaling attacks and for filtering attacks..please help me if possible.i need it badly
Image Analyst
on 23 Apr 2022
Yep, I anticipated your next question perfectly.
Again, sorry I don't have any code to do that. I'd have to spend days developing it just like you will, or months like the people who wrote those papers did. If I had such code or could write it in 5 minutes or less, I'd give it to you. But I'm sure it's not trivial. That said, once you write your code if you have questions about an error message, we can answer that. But we can't write a whole turnkey application suite for you. We just don't have that much time to donate to you. I'm sure there are graduate students making image forensics their entire masters or Ph.D., so it's not trivial.
If you really need it done and can't do it yourself, the Mathworks would be delighted to write the code for you. Contact their consulting department here:
Of course they don't do it for free so you have to decide how much it's worth to you do get it done.
Walter Roberson
on 23 Apr 2022
The code you attached appears to be from https://github.com/ShurenQi/FGPCET . You would need the rest of that third-party code in order to run that file.
Sunita Pradhan
on 24 Apr 2022
i have that file but i cant run different attacks on it.please help me..i need it..badly..please
Sunita Pradhan
on 24 Apr 2022
can you please check the file error...and help me to solve the issue.
clc
close all
%Original Image
host=imread('128.jpg');
subplot(1,3,1)
figure(1);
imshow(host);
title('Original color image');
[h_LL,h_LH,h_HL,h_HH]=dwt2(host,'haar');
img=h_LL;
%watermark Image
watermark=imread('32.jpg');
watermark=imresize(watermark,[m n])
subplot(1,3,2)
figure(2);
imshow(watermark);
title('Watermark image');
[w_LL,w_LH,w_HL,w_HH]=dwt2(watermark,'haar');
img_wat=w_LL;
% watermark embedding
wd_LL=h_LL+(0.03*w_LL);
%output
watermarked=idwt2(wd_LL,h_LH,h_HL,h_HH,'haar');
imwrite(uint8(watermarked),'Watermarked.jpg');
subplot(1,3,1)
imwrite(res,'DwtwatermarkedImage.jpg','jpg');
figure(3);
res=((uint8(watermarked)));
imshow(res);
title('Watermarked Image');
inputImage=res;
wm=imread(res);
[wm_LL,wm_LH,wm_HL,wm_HH]=dwt2(wm,'haar');
%watermark extraction
ewat=(wm_LL-h_LL)/0.03;
%output
watermarked=idwt2(ewat,w_LH,w_HL,w_HH,'haar');
figure(4);imshow(uint8(watermarked));
op=((uint8(watermarked)));
imwrite(uint8(watermarked),'EWatermark.jpg');title('Extracted Watermark');
mse_extraction=MSE(res,op)
psnr=PSNR(res,op)
Image Analyst
on 24 Apr 2022
You forgot to attach the error. Please include ALL the red text. And we can't run your code anyway because you forgot to attach 128.jpg and 32.jpg.
Sunita Pradhan
on 24 Apr 2022
Image Analyst
on 24 Apr 2022
You need to assign m as the number of rows you want the resized image to be after resizing. Right now it's unknown/unassigned.
Image Analyst
on 24 Apr 2022
Perhaps you mean
[hostRows, hostColumns, hostNumColorChannels] = size(host);
watermark=imresize(watermark, [hostRows, hostColumns]);
which will resize the watermark image to be the same size as the host image.
Sunita Pradhan
on 25 Apr 2022
Walter Roberson
on 25 Apr 2022
One of the arrays is based on the size of the original image. The other is based on the size of the 32 x 32 watermark. There is not going to be any way to add them together.
Sunita Pradhan
on 25 Apr 2022
Image Analyst
on 25 Apr 2022
I computed that here:
[hostRows, hostColumns, hostNumColorChannels] = size(host);
Notice that I did not use cryptics one-letter variable names that make your code look like an undecyperable alphabet soup mess of a code. I used descriptive variable names where it's glaring obvious what the variables recomment - a practice I hope you'll follow. If you still don't know, then
m = hostRows
n = hostColumns
p = hostNumColorChannels
For your error, it's saying that the two matrices are different sizes so you can't add them together. Put these lines in your code before the error line:
[LLRows, LLColumns, LLNumColorChannels] = size(watermarked_LL)
[hostLLRows, hostLLColumns, hostLLNumColorChannels] = size(host_LL)
What does that report to the command window? Evidently something does not match up.
Walter Roberson
on 25 Apr 2022
read the documentation for dwt2 https://www.mathworks.com/help/wavelet/ref/dwt2.html#d123e27693 and see that the first output is half the size of the input. You resized your watermark to 32 by 32 so your first output from dwt2 of that would be about 16 x 16.
In order to be able to add that 16 x 16 array to the output of the dwt2 from the original image, that other dwt2 would also have to be 16 x 16. Which would require that the original image is 32 x 32. But that is clearly not the case.
You have a small number of options at this point:
1. You can resize the original image to 32 x 32 as well 2. You can resize the watermark to the same size as the image 3. you can give up on trying to add those matrices together 4. you can choose a subset of the larger dwt2 result to add the watermark to, leaving the rest unchanged.
SrinivasHarsha
on 26 Apr 2022
Hi Image Analyst,
we need a help from you
can you send a response to my mail if possible.
we will contact you reg: image processing help
my mail id: srinivas.nato@gmail.com
SrinivasHarsha
on 26 Apr 2022
Hi Image Analyst,
we need a help from you
can you send a response to my mail if possible.
we will contact you reg: image processing help
my mail id: srinivas.nato@gmail.com
Walter Roberson
on 26 Apr 2022
Image Analyst does not volunteer email support. He will not help you through email.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)