当前位置:网站首页>Chi-square distribution of digital image steganography
Chi-square distribution of digital image steganography
2022-07-31 01:14:00 【Tea drinking the glass of】
一、实验目的
1、Implement the chi-square analysis algorithm;
2、The chi-square analysis can be used to distinguish warpsLSBSteganographic secret image and original image without modification by steganography algorithm.
二、问题描述
1.输入的形式和输入值的范围;
84张bmpformatted standard image;
2.输出的形式;
task1:The chi-square analysis comparison plot of the secret image and the original image, and the dividing line;
task2:使用task1split value in TTest the image type,Get the prediction accuracy;
3.程序所能达到的功能.
The dense image and the original image can be distinguished by chi-square distribution test or eigenvalue test.
task1:通过84Zhang standard library images are obtained by embedding secret information84Image of Zhang Zaimi,对共168Two different chi-square analyses were performed on the images,The chi-square value comparison chart and segmentation value under two different chi-square analysis methods are obtainedT;
task2:利用84standard library images,将前42Embed the secret information to form a secret image,后42No secret information is embedded as the original image,测试由task1The resulting split valueTUsed to distinguish image types(Original image or contained image)的预测准确度.
三、实验原理
简单LSBSteganographic algorithm pixel value modification analysis:
像素值2i改为2i+1或将2i+1改为2i,embedded datad=0/1,其概率为50%.
Note the grayscale valuej的像素数目为hj
The steganographic image is compared to the original image:
Steganographic imagesh2i、h2i+1value will be closer(Histograms come in pairs),图1is the histogram of the original image,图2is the histogram of the steganographic image.
图1
图2
Find the smallest satisfy that fits the statistical image,Then, it can be known that the image belongs to a steganographic image or an original image by judging the size relationship between and.
四、实验设计
主函数task1.m和task2.m调用函数StgPrb.m和函数Diff.m
task1利用84standard images as input,By embedding secret information,得到84Zhang Zaimi's image,using the total168Chi-square analysis was performed on the images,Get the predicted split valueTAnd the chi-square value comparison chart.
Chi-square analysis1The comparison chart of the original image and the chi-square value of the dense image,如图3所示;
图3
The chi-square analysis method1The results are processed logarithmically,make the result more obvious,Reduces the magnitude of the difference in chi-square values,入图4;
图4
Chi-square analysis2The comparison chart of the original image and the chi-square value of the dense image,如图5所示;
图5
task2利用84standard images as input,其中前42The image embedding secret information makes its image embedding rate 1,后42images do not embed any information,Then by calling the functionStgPrb.m和函数Diff.mGet the chi-square value of the image,Combine it with the split valueT进行对比判断,Predict the specific type of this image.Compare the predicted type with the actual type,That is, the prediction accuracy can be obtained.
其中使用函数StgPrb.m的预测精度为100%,使用函数Diff.m的预测精度为98.81%.
如下图6为检测方法1The actual and predicted type of the image,其中1Indicates the encrypted image,0表示原始图像.
图6
如下图7为检测方法2The actual and predicted type of the image,其中1Indicates the encrypted image,0表示原始图像.
图7
5.总结
在设计完Diff.m函数之后,It is found that the chi-square values of different images are very different,通过logThe function reduces the order of magnitude of the chi-square value for different images,Makes the chi-square results for different types of images more obvious.
Found a better way of chi-square analysis online,其通过chi2cdfThe function cleverly makes the scattered values more regular,Finally, the chi-square value of most secret images is reached1,The chi-square value of the original image0.测试以0.5When judging the image type for the split value,The prediction accuracy is high100%.
6.附录代码
task1.m
%% 清空环境
clc
clear
close all
%% 数据测试(84个训练图像)
cover=cell(84,1);
stego=cell(84,1);
sizes=zeros(84,2);
p1=zeros(84,2);
p2=zeros(84,2);
for k=1:84
secret=rand(512)<0.5;
%% 读取图像
text=['original/',num2str(k),'.bmp'];
cover{k}=imread(text);
[sizes(k,1),sizes(k,2)]=size(cover{k});
%% 求卡方值
p1(k,1)=StgPrb(cover{k});
%% 求特征值
p2(k,1)=Diff(cover{k});
%% 嵌入信息
for i=1:sizes(k,1)
for j=1:sizes(k,2)
stego{k}(i,j)=bitset(cover{k}(i,j),1,secret(i,j));
end
end
%% 求卡方值
p1(k,2)=StgPrb(stego{k});
%% 求特征值
p2(k,2)=Diff(stego{k});
end
T=max(p2(:,2));
figure();
plot([1:84],p2(:,1),'r+',[1:84],p2(:,2),'b+',[1:84],ones(84,1).*T,'g-');
legend('原始图像','嵌入率为1Confidential image of ','分割线T');
xlabel('图像编号');
ylabel('特征值');
figure();
p2=log(p2);
T=log(T);
plot([1:84],p2(:,1),'r+',[1:84],p2(:,2),'b+',[1:84],ones(84,1).*T,'g-');
legend('原始图像','嵌入率为1Confidential image of ','分割线T');
xlabel('图像编号');
ylabel('log(特征值)');
figure();
plot([1:84],p1(:,1),'r+',[1:84],p1(:,2),'b+');
legend('原始图像','嵌入率为1Confidential image of ');
xlabel('图像编号');
ylabel('卡方值');
save T.mat T
task2.m
clc
clear
close all
load T.mat
%% 数据测试(84个测试图像)
cover=cell(84,1);
p1=zeros(84,1);
p2=zeros(84,1);
predict=zeros(84,2);
for k=1:42
secret=rand(512)<0.5;
%% 读取图像
text=['original/',num2str(k),'.bmp'];
cover{k}=imread(text);
[sizes(k,1),sizes(k,2)]=size(cover{k});
%% 嵌入信息
for i=1:sizes(k,1)
for j=1:sizes(k,2)
cover{k}(i,j)=bitset(cover{k}(i,j),1,secret(i,j));
end
end
%% 求卡方值
p1(k)=StgPrb(cover{k});
%% 求特征值
p2(k)=Diff(cover{k});
p2(k)=log(p2(k));
if p1(k)>0.5
predict(k,1)=1;
else
predict(k,1)=0;
end
if p2(k)>T
predict(k,2)=0;
else
predict(k,2)=1;
end
end
for k=43:84
%% 读取图像
text=['original/',num2str(k),'.bmp'];
cover{k}=imread(text);
[sizes(k,1),sizes(k,2)]=size(cover{k});
%% 求卡方值
p1(k)=StgPrb(cover{k});
%% 求特征值
p2(k)=Diff(cover{k});
p2(k)=log(p2(k));
if p1(k)>0.5
predict(k,1)=1;
else
predict(k,1)=0;
end
if p2(k)>T
predict(k,2)=0;
else
predict(k,2)=1;
end
end
%% Find the prediction accuracy
predict_rate1=0;
predict_rate2=0;
for k=1:42
if predict(k,1)==1
predict_rate1=predict_rate1+1;
end
if predict(k,2)==1
predict_rate2=predict_rate2+1;
end
end
for k=43:84
if predict(k,1)==0
predict_rate1=predict_rate1+1;
end
if predict(k,2)==0
predict_rate2=predict_rate2+1;
end
end
predict_rate1=predict_rate1/84
predict_rate2=predict_rate2/84
dx=[1:84];
real=[ones(1,42),zeros(1,42)];
figure();
plot(dx,real,'r*',dx,predict(:,1),'bo');
title("检验方法1");
legend('实际类型','预测类型');
figure();
plot(dx,real,'r*',dx,predict(:,2),'bo');
title("检验方法2");
legend('实际类型','预测类型');
StgPrb.m
function p=StgPrb(x)
n=sum(hist(x,[0:255]),2);
h2i=n([3:2:255]);
h2is=(h2i+n([4:2:256]))/2;
filter=(h2is~=0);
k=sum(filter);
idx=zeros(1,k);
for i=1:127
if filter(i)==1
idx(sum(filter(1:i)))=i;
end
end
r=sum(((h2i(idx)-h2is(idx)).^2)./(h2is(idx)));
p=1-chi2cdf(r,k-1);
Diff.m
function p=Diff(x)
p=0;
[n,~]=imhist(x);
for i=0:127
p=p+(n(2*i+1)-n(2*i+2))^2;
end
边栏推荐
- 【网络安全】文件上传靶场通关(1-11关)
- 场景之多数据源查询及数据下载问题
- 孩子的编程启蒙好伙伴,自己动手打造小世界,长毛象教育AI百变编程积木套件上手
- Problem record in the use of TypeScript
- ShardingSphere之未分片表配置实战(六)
- Basic Parameters of RF Devices 2
- 《实战》基于电商领域的词性提取及其决策树模型建模
- Distributed. Distributed lock
- Bert usage and word prediction based on Keras_bert model
- Huawei's "genius boy" Zhihui Jun has made a new work, creating a "customized" smart keyboard from scratch
猜你喜欢
随机推荐
typescript14-(单独指定参数和返回值的类型)
typescript18-对象类型
297. 二叉树的序列化与反序列化
小黑leetcode之旅:104. 二叉树的最大深度
Rocky/GNU之Zabbix部署(3)
24. Please talk about the advantages and disadvantages of the singleton pattern, precautions, usage scenarios
孩子的编程启蒙好伙伴,自己动手打造小世界,长毛象教育AI百变编程积木套件上手
《实战》基于电商领域的词性提取及其决策树模型建模
这个项目太有极客范儿了
Sping.事务的传播特性
typescript17-函数可选参数
Mysql: Invalid default value for TIMESTAMP
The level of ShardingSphere depots in actual combat (4)
The client series of the DOM series
typescript10-commonly used basic types
typescript16-void
typescript13 - type aliases
4G通信模块CAT1和CAT4的区别
BOM系列之history对象
Unity2D horizontal version game tutorial 4 - item collection and physical materials