coxextract.m

来自「这是一个关于信息隐藏的源代码,是用vc++开发」· M 代码 · 共 48 行

M
48
字号
%CoxExtract.m
function X = CoxExtract(I, J, alpha, N)
%COXEXTRACT Extract a watermark from an image
%   Given an original image I and a watermarked version J
%   (probably modified), COXEXTRACT extracts a watermark
%   from J using some knowledge about I.
%
%   See: COXWMK, COXDETECT, COXTEST, SIM

%   This is a modified version of Fabien Petitcolas' implementation
%   of Cox's technique by Gabriela Delfino and Fabian Martinez
%
%   Fabien Petitcolas' website: http://www.cl.cam.ac.uk/~fapp2

if (nargin == 2)
   N = 1000;
%  alpha = 0.1;
   alpha = 0.1;
end
if (nargin == 3)
   N = 1000;
end

if (isrgb(I))
   error('Use grayscale image only');
end

sI = size(I);
if ((sI(1) * sI(2)) < N)
   error('Image too small or too many coefficients');
end
sJ = size(J);
if ((sI(1) ~= sJ(1)) | (sI(2) ~= sJ(2)))
   error('The images have different size.');
end

% Compute the DCT of the images
DCTI = dct2T(I);
DCTJ = dct2T(J);

% Find the N largest coefficients in the DCT matrix
Index = FindNLargest(abs(DCTI), N);

% Extract the watermark
for i = 1:N
   X(i) = (DCTJ(Index(1, i), Index(2, i)) / DCTI(Index(1, i), Index(2, i)) - 1) / alpha;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?