Filter löschen
Filter löschen

Image encoding matlab code

4 Ansichten (letzte 30 Tage)
marie lasz
marie lasz am 6 Dez. 2020
Kommentiert: Rik am 7 Dez. 2020
hello
this code is working perfectly but it is embedding secret message in upper left square only. but I want to embedd on every block i.e i have 64x64 blocks , in each bloock there are 8x8 blocks. I am a bit confused but would be grateful for any help because i am a beginner level of matlab.
mark=imbinarize(Watermark_Image);
marksize=size(mark);
rm=marksize(1); %rowMat is the number of lines of the watermark image
cm=marksize(2);
figure(1);subplot(2,3,2);imshow(Watermark_Image),title('Watermark image');
T = dctmtx(8);
alpha=105; %The scale factor, which controls the strength of the watermark addition, determines how much the frequency domain coefficients are modified
k1=randn(1,8); %Generate two different random sequences, ruturns nxm matrix of normally distributed random numbers
k2=randn(1,8);
Dct_Image=blkproc(Y,[8 8],'dct2');
Output_Image=Dct_Image;
for E=1:4096
for i=1:rm
for j=1:cm
x=(i-1)*8;
y=(j-1)*8;
if mark(i,j)==1
k=k1;
else
k=k2;
end
% Output_Image(x,y)=Dct_Image(x,y)+alpha*k;
Output_Image(x+1,y+8)=Dct_Image(x+1,y+8)+alpha*k(1);
Output_Image(x+2,y+7)=Dct_Image(x+2,y+7)+alpha*k(2);
Output_Image(x+3,y+6)=Dct_Image(x+3,y+6)+alpha*k(3);
Output_Image(x+4,y+5)=Dct_Image(x+4,y+5)+alpha*k(4);
Output_Image(x+5,y+4)=Dct_Image(x+5,y+4)+alpha*k(5);
Output_Image(x+6,y+3)=Dct_Image(x+6,y+3)+alpha*k(6);
Output_Image(x+7,y+2)=Dct_Image(x+7,y+2)+alpha*k(7);
Output_Image(x+8,y+1)=Dct_Image(x+8,y+1)+alpha*k(8);
end
end
end
% firsttX = blkproc(after,[8,8], 'P1*x', mask);
resultY=uint8(blkproc(Output_Image,[8 8], 'idct2'));
  5 Kommentare
marie lasz
marie lasz am 6 Dez. 2020
@kalyan you can take any image of 32x32 for watermark and 512x512 for hoat image.
Rik
Rik am 7 Dez. 2020
I restored the original post from Google cache. @Marie, don't remove crucial parts of your question.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 6 Dez. 2020
The easy way is to just resize your image to one 64x64 thumbnail, and then replicate it to make a tiled image the same size as your cover image. You might use repmat(), imtile(), or montage(). Or see my attached demo.
I put the watermark into bitplane 6 so you can see it replicated a little bit in the middle image of the right column. Adapt as needed.
  2 Kommentare
Image Analyst
Image Analyst am 6 Dez. 2020
Marie, not sure what your edit was. But did this work for you?
marie lasz
marie lasz am 7 Dez. 2020
Good Morning,
I didn't try that because it is changing the whole criteria. I will try that later but now trying to fix this as per requirement.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by