• 大小: 0.37M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-04-27
  • 语言: Matlab
  • 标签: matlab  

资源简介

Image Steganograpy using Pixel-Value Differencing

资源截图

代码片段和文件信息

clc;
close all;
clear;

%%%%%%%%%%%%%%%%%%%%%%% Reading a Secret Text File %%%%%%%%%%%%%%%%%%%%%%%%
file_id = fopen(‘message.txt‘‘r‘);
file_content = fread(file_id);
file_length = length(file_content);
in = [];
in = [in dec2bin(file_length20)]; %character to binary conversion 
for i=1:file_length                                         
    in=[in dec2bin(file_content(i)7)];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%% Reading Cover Image %%%%%%%%%%%%%%%%%%%%%%%%%%%
cover_image = imread(‘cover_image.bmp‘); %get cover image                                        
red = cover_image(::1); %seperating rgb values 
blue = cover_image(::2);
green = cover_image(::3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% embedding Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
color = red; %red color selected for embedding
[rc] = size(color);
final = double(color); 
next=0;
capacity=0; %total no of bits that can be embedded

for x=0:1:r-1 
    for y=0:2:c-1
        enable = 1; %enable=0 when new pixels may fall off the boundary
        p = color(1+x1+y:2+y); %block of two pixels pi & pi+1
        p = double(p);
        d = p(12) - p(11); %d = difference between 2 pixel
        d_abs = abs(d); %absolute difference
        lb=[0 8 16 32 64 128]; %lowerbound
        ub=[7 15 31 63 127 255]; %upperbound
        for i=1:1:6 %test the R boundary
            if((d_abs >= lb(i)) && (d_abs <= ub(i))) %selecting range
                %check if any pixel in a block fall off the boundary [0255]
                even2 = mod(d2); 
                m2 = ub(i) - d;
                if (even2 == 0)
                    Pcheck=[p(11)-floor(m2/2) p(12)+ceil(m2/2)];
                else
                    Pcheck=[p(11)-ceil(m2/2) p(12)+floor(m2/2)];
                end
                if(Pcheck(1)<0 || Pcheck(2)<0 || Pcheck(1)>255 || Pcheck(2)>255)
                    enable = 0;
                    break
                end
                
                n = ub(i)-lb(i)+1; %quantization width of range
                t = floor(log2(n)); %maximum bit can be embedded in 2 pixels
                capacity=capacity+t; %max capacity of the cover image 
                
                %check if next exceeds the length of message
                if(next>length(in)) 
                    m=0;
                %check if next+t exceeds the length of message
                elseif(next+t>length(in)) 
                    if(1+next>=length(in))
                        k=zeros(1t);
                    else
                        k=in(1+next:length(in));
                    end
                    diff =next+t-length(in);
                    k1=zeros(1t);
                    if(diff>0)
                        for j=1:next+t-length(in)
                            k1(j)=k(j);
                    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     786486  2012-05-12 18:09  Image_Steg\cover_image.bmp

     文件      12342  2012-05-09 23:43  Image_Steg\cover_image2.bmp

     文件       4951  2012-05-27 16:40  Image_Steg\data_embedding.m

     文件       2743  2012-05-27 21:24  Image_Steg\data_extraction.m

     文件       2735  2012-05-27 01:27  Image_Steg\histogram_analysis.m

     文件       4757  2012-05-27 18:15  Image_Steg\message.txt

     文件        923  2012-05-27 16:31  Image_Steg\psnr.m

     文件        897  2012-05-27 18:13  Image_Steg\Read Me Please!.txt

     目录          0  2012-10-10 13:30  Image_Steg

----------- ---------  ---------- -----  ----

               815834                    9


评论

共有 条评论