声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1259|回复: 1

[综合讨论] Error: Missing variable or function.

[复制链接]
发表于 2009-5-12 20:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
%COXWMK Insert a random watermark.
%   [J, W] = COXWMK(I) watermarks the grayscale picture I using
%   Cox's scheme [2] with default parameters. J is the watermarked
%   picture and W is the watermark.
%   The watermark W is drawn from a Normal random process N(0,1)
%   if it is not given by the user as last parameter.
%
%   [J, W] = COXWMK(I, Alpha, N) watermarks the grayscale picture I
%   using modifying the Nth largest DCT coefficients v_i in the
%   following way: v_i := v_i * (1 + Alpha * w_i) where w_i
%   are the components of the watermak.
%
%   Use IMSHOW(mat2gray(J)) to display the output.
%
%   See: COXDETECT

%   Fabien A.P. Petitcolas 26-11-97
%   Copyright (c) 1997 by the University of Cambridge
%   $Revision: 0.6$

%   References:
%        1) Ross J. Anderson,7 editor. Information hiding: first
%           international workshop, volume 1174 of Lecture notes
%           in computer science. University of Cambridge, Isaac
%           Newton Institute, Springer Verlag, Berlin, Germany,
%           May 1996.
%        2) Ingemar J. Cox, Joe Kilian, Tom Leighton, and Talal
%           Shamoon. A secure, robust watermark for multimedia.
%           In Anderson [1], pages 183-206
function [J, W] = CoxWmk(I, alpha, N,w)
if (nargin == 1)
   N = 1000;
   alpha = 0.1;
   W = randn(1,N);
elseif (nargin == 2)
   N = 1000;
   W = randn(1,N);
elseif (nargin == 3)
   W = randn(1,N);
end

sI = size(I);
if ((sI(1) * sI(2)) < N)
   error('Image too small or too many coefficients.');
end

% Generate the random watermark
%W = randn(1,N);

% Compute the DCT of the image
DCTI = dct2(I);

% Find the N largest coefficients in the DCT matrix
% Better if the extraction of the N largest was done
% at the same time than the computation of the DCT...
Index = FindNLargest(abs(DCTI), N);

% Modify these coefficients
for i = 1:N
   DCTI(Index(1,i),Index(2,i)) = DCTI(Index(1,i),Index(2,i)) * (1 + alpha * W(i));
end

% Simply take the inverse DCT of the modifyied matrix
J = idct2(DCTI);
subplot(1,2,1);imshow(I);title("原始图像");
subplot(1,2,2);imshow(J);title("加入水印图像");
imwrite(J,"graywatermark.jpg");
运行此函数提示Error: Missing variable or function.不知怎么回事,求教。
回复
分享到:

使用道具 举报

发表于 2009-5-12 21:35 | 显示全部楼层
个人水平专业有限, 建议楼主说清楚些!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-19 04:29 , Processed in 0.058430 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表