资源简介
JSteg隐写算法,基于DCT系数的变换进行数字隐写,matlab代码,已实现,可运行。主要思想是将秘密消息嵌入在量化后的DCT系数的最低比特位上,但对原始值为0、1的DCT系数不进行嵌入。
代码片段和文件信息
clc
clear all;% clear all variables from previous sessions
close all;
covername = input(‘Enter image file name with extension: ‘ ‘s‘);
messagename = input(‘Enter message image file name with extension: ‘ ‘s‘);
cover = imread(covername);
sz = size(cover);
rows = sz(11);
cols = sz(12);
colors = max(max(cover));
%r=1;
%for i=1:rows
% for j=1:3:cols
% rgb(r1)=cover(ij);
% rgb(r2)=cover(ij+1);
% rgb(r3)=cover(ij+2);
% r=r+1;
% end
%end
%gray=rgb2gray(rgb);
%cover=gray;
fd = fopen (messagename ‘r‘);
message = fgetl(fd);
messagelength = length(message);
figure(1) imshow(cover); title(‘Original Image (Cover Image)‘);
%disp(message);
%cover=double(cover);
%message=double(message);
message = uint8(message);
coverzero = cover;
%disp(coverzero);
%coverzero=imread(‘GrayScale.bmp‘);
quant_multiple = 1;
blocksize = 8;
DCT_quantizer = ...
[ 16 11 10 16 24 40 51 61; ...
12 12 14 19 26 58 60 55; ...
14 13 16 24 40 57 69 56; ...
14 17 22 29 51 87 80 62; ...
18 22 37 56 68 109 103 77; ...
24 35 55 64 81 104 113 92; ...
49 64 78 87 103 121 120 101; ...
72 92 95 98 112 100 103 99 ];
%figure(1)
%image(coverzero)
figure(2);imshow(coverzero);
%colormap(map)
title(‘Original image‘);
%figure(2)
%coverzero = coverzero - ceil(colors/2);
%figure(2);imshow(coverzero);
pad_cols = (1 - (cols/blocksize - floor(cols/blocksize))) * blocksize;
if pad_cols == blocksize pad_cols = 0; end
pad_rows = (1 - (rows/blocksize - floor(rows/blocksize))) * blocksize;
if pad_rows == blocksize pad_rows = 0; end
for extra_cols = 1:pad_cols
coverzero(1:rows cols+extra_cols) = coverzero(1:rows cols);
end
cols = cols + pad_cols; % coverzero is now pad_cols wider
for extra_rows = 1:pad_rows
coverzero(rows+extra_rows 1:cols) = coverzero(rows 1:cols);
end
rows = rows + pad_rows; % coverzero is now pad_rows taller
for row = 1: blocksize: rows
for col = 1: blocksize: cols
DCT_matrix = coverzero(row: row + blocksize-1 col: col + blocksize-1);
DCT_matrix = DCT2(DCT_matrix);
% quantize it (levels stored in DCT_quantizer matrix):
%DCT_matrix = floor (DCT_matrix ...
% ./ (DCT_quantizer(1:blocksize 1:blocksize) * quant_multiple) + 0.5);
DCT_matrix = round(DCT_matrix ...
./ (DCT_quantizer(1:blocksize 1:blocksize) * quant_multiple));
%DCT_matrix=round(DCT_matrix);
% place it into the compressed-image matrix:
jpeg_img(row: row + blocksize-1 col: col + blocksize-1) = DCT_matrix;
end
end
figure(3);hist(jpeg_img);
figure(4);imshow(jpeg_img);
bitlength=1;
%messagebit=zeros(messagelength*8);
for i=1:messagelength
%imbed=7;
for imbed=1:8
messageshift=bitshift(message(i)8-imbed);
showmess=uint8(messageshift);
s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 10091 2003-07-31 08:05 lenna.JPG
文件 786486 2010-05-19 22:51 pepper.bmp
文件 7280 2014-09-26 09:34 Jsteg.m
文件 263222 2010-05-19 22:45 lena512.bmp
----------- --------- ---------- ----- ----
1067079 4
- 上一篇:并联机器人动力学matlab求解
- 下一篇:LFM匹配滤波
评论
共有 条评论