资源简介
nsf5隐写方法代码,matlab实现的,对于想学习隐写方法的同学很有用。
代码片段和文件信息
function [nzACembedding_efficiencychanges] = nsf5_simulation(COVERSTEGOALPHASEED)
% -------------------------------------------------------------------------
% Contact: jan@kodovsky.com | June 2011
% -------------------------------------------------------------------------
% This program simulates the embedding impact of the steganographic
% algorithm nsF5 [1] as if the best possible coding was used. Please visit
% the webpage http://dde.binghamton.edu/download/nsf5simulator for more
% information.
% -------------------------------------------------------------------------
% Input:
% COVER - cover image (grayscale JPEG image)
% STEGO - resulting stego image that will be created
% ALPHA - relative payload in terms of bits per nonzero AC DCT coefficient
% SEED - PRNG seed for the random walk over the coefficients
% Output:
% nzAC - number of nonzero AC DCT coefficients in the cover image
% embedding_efficiency - bound on embedding efficiency used for simulation
% changes - number of changes made
% -------------------------------------------------------------------------
% References:
% [1] J. Fridrich T. Pevny and J. Kodovsky Statistically undetectable
% JPEG steganography: Dead ends challenges and opportunities. In J.
% Dittmann and J. Fridrich editors Proceedings of the 9th ACM
% Multimedia & Security Workshop pages 3-14 Dallas TX September
% 20-21 2007.
% -------------------------------------------------------------------------
% Note: The program requires Phil Sallee‘s MATLAB JPEG toolbox available at
% http://www.philsallee.com/
% -------------------------------------------------------------------------
%%% load the cover image
try
jobj = jpeg_read(COVER); % JPEG image structure
DCT = jobj.coef_arrays{1}; % DCT plane
catch
error(‘ERROR (problem with the cover image)‘);
end
if ALPHA>0
%%% embedding simulation
embedding_efficiency = ALPHA/invH(ALPHA); % bound on embedding efficiency
nzAC = nnz(DCT)-nnz(DCT(1:8:end1:8:end)); % number of nonzero AC DCT coefficients
changes = ceil(ALPHA*nzAC/embedding_efficiency); % number of changes nsF5 would make on bound
changeable = (DCT~=0); % mask of all nonzero DCT coefficients in the image
changeable(1:8:end1:8:end) = false; % do not embed into DC modes
changeable = find(changeable); % indexes of the changeable coefficients
rand(‘state‘SEED); % initialize PRNG using given SEED
changeable = changeable(randperm(nzAC)); % create a pseudorandom walk over nonzero AC coefficients
to_be_changed = changeable(1:changes); % coefficients to be changed
DCT(to_be_changed) = DCT(to_be_changed)-sign(DCT(to_be_changed)); % decrease the absolute value of the coefficients to be changed
end
%%% save the resulting stego image
try
jobj.coef_arrays{1} = DCT;
jobj.optimize_coding = 1;
jpeg_write(jobjSTEGO);
catch
error(‘ERROR (problem with saving the st
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-06-20 15:09 nsf5_simulation\
文件 43401 2011-05-12 11:56 nsf5_simulation\cover.jpg
文件 17765 2005-06-01 11:46 nsf5_simulation\jpeg_read.mexa64
文件 65536 2007-02-14 10:31 nsf5_simulation\jpeg_read.mexw32
文件 17263 2006-09-28 00:28 nsf5_simulation\jpeg_write.mexa64
文件 57344 2006-09-28 00:28 nsf5_simulation\jpeg_write.mexw32
文件 3245 2011-06-20 15:09 nsf5_simulation\nsf5_simulation.m
文件 816 2011-06-19 22:35 nsf5_simulation\test.m
- 上一篇:matlab中滑动窗口实现
- 下一篇:LSB匹配隐写代码
评论
共有 条评论