How to embed image watermark bits into histogram of the audio file?
Show older comments
I have an image watermarks that is converted into binary bits and histogram of an audio wav file. I need to embed the watermarking bits in the histogram.
close all;
clc;
% read image
[embededimage_fname, image_pthname] = ...
uigetfile('*.jpg; *.png; *.tif; *.bmp', 'Select the Cover Image');
if (embededimage_fname ~= 0)
embedded_image = strcat(image_pthname, embededimage_fname);
embedded_image = double( rgb2gray( imread( embedded_image ) ) );
embedded_image = imresize(embedded_image, [512 512], 'bilinear');
else
return;
end
% read audio
[watermarkAudio_fname, watermark_pthname] = ...
uigetfile('*.wav', 'Select the Watermark audio');
if (watermarkAudio_fname ~= 0)
watermark_audio = strcat(watermark_pthname, watermarkAudio_fname);
[n, fs] = audioread(watermark_audio); % "n" is number of samples and fs is the sample rate
%watermark_audio = imresize(watermark_audio, [512 512], 'bilinear');
else
return;
end
imbin_seq = reshape(dec2bin(embedded_image, 8) - '0', 1, []);
% To calculate modified mean
na = 2^15;
n = n*na;
nLength = length(n);
modified_mean = mean(abs(n));
% Embedding Range
lmda = 2.4; %pick any value of lmda from the range (2.0, 2.5);
e_range = ceil(lmda * modified_mean);
%number of bins and Bin Width
h = histogram(n);
Bin_Num = h.NumBins();
Bin_Width = h.BinWidth();
Now, my next step is selecting three consecutive bins of the histogram and then 1 bit of watermark is embeded into these 3 bins. I am not getting how to this embedding, suggest me how to perform this watermarking??
Thanks in Advance!!!!
12 Comments
Walter Roberson
on 9 Mar 2019
This is an algorithm question rather than a MATLAB question.
I do not understand how watermarking the audio histogram would be of any use with a cover image since you are not embedding the audio in the image. I could understand if you were embedding audio bits into the histogram of the image with an image result.
Bhavneet Sharma
on 9 Mar 2019
Walter Roberson
on 9 Mar 2019
Supposing that you had the watermarked audio: then what? What does it have to do with the image? And remind me where you are getting the bits to watermark into the audio ??
Normally you would either use bits of the image to watermark the audio, or bits of the audio to watermark the image, but at the moment you just have an image floating around unused, and you have an audio that is being used to watermark itself.
Bhavneet Sharma
on 9 Mar 2019
Walter Roberson
on 9 Mar 2019
robust against attacks would be difficult .
this is not a matlab question . you should be research in papers and literature .
Bhavneet Sharma
on 9 Mar 2019
Walter Roberson
on 9 Mar 2019
v = h.Values;
next_3 = ceil(Bin_Num/3)*3;
augmented_v = nan(1, next_3);
augmented_v(1:Bin_Num) = v;
bins_by_3 = reshape(augmented_v, 3, 1);
Now every column of bins_by_3 is a group of three bin counts, except that the last one or two entries of the last column will be nan if the number of bins was not a multiple of 3.
Note that some of the counts might be 0.
If it is acceptable to have the final values (where number of bins is not a multiple of 3) be 0 instead of nan, and you have the signal processing toolbox, then the above code can be replaced with
bins_by_3 = buffer(h.Values, 3);
Bhavneet Sharma
on 10 Mar 2019
Walter Roberson
on 10 Mar 2019
The line before that creates augmented_v as all nan and a length that is a multiple of 3.
The line you indicate assigns the actual v to the the beginning of the array, leaving nan in the spaces needed to pad with.
Another way of writing this would have been
augmented_v = [v, nan(1, next_3 - Bin_Num)];
which would start with the existing v and then add on 0, 1, or 2 nan as needed to make the overall a multiple of 3 long.
Bhavneet Sharma
on 12 Mar 2019
Edited: Bhavneet Sharma
on 12 Mar 2019
Walter Roberson
on 12 Mar 2019
it is a 2d array . Each column is a group of 3 bins.
Bhavneet Sharma
on 13 Mar 2019
Answers (0)
Categories
Find more on Watermarking in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!