Home > Software engineering >  Why a Jsteg steganalysis algorithm after feeling image doesn't change?
Why a Jsteg steganalysis algorithm after feeling image doesn't change?

Time:11-10

CLC
clear all;
close all;

% messagename=input (" Enter the message file name with the extension: ', 's');
Covername='1. JPG';
Messagename='message. TXT';
Stegomessagename='stego. TXT';
Cover=imread (covername);

Sz=size (cover);
Rows=sz (1, 1);
Cols=sz (1, 2);
Colors=Max (Max (cover));

Fd=fopen (messagename, 'r');
Message=fgetl (fd);
% message='hello world';
Messagelength=length (the message);

% figure (1), imshow (cover); The title (' OriginalImage (CoverImage) ');
Message=uint8 (message);
Coverzero=cover;

Cover=rgb2gray (cover);

Blocksize=8;
Quant_multiple=1;
DCT_quantizer=...
[16 November 10 40 51, 61, 16 and 24...
12 12 of 14 19 26 58, 60 55; .
14 and 16 24 40 57 6, 956; .
14 of 17 and 29 51, 87, 80, 62; .
18 and 22 and 56 68 109 103 77; .
24 and 35 to 55 64 81 104 113 92; .
49 64 78 87 103 121 120 101; .
72 92 95 98 112 100 103 99];

Figure (2); Imshow (coverzero);
The title (' OriginalImage ');

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; % coverzeroisnowpad_colswider
For extra_rows=1: pad_rows
Coverzero (rows + extra_rows, 1: cols)=coverzero (rows, 1: cols);
End

Rows=rows + pad_rows;

For row=1: blocksize: rows
For col=1: blocksize: cols
DCT_matrix=coverzero (col: row, row + blocksize - 1, col + blocksize - 1);
DCT_matrix=dct2 (DCT_matrix); % quantizeit (levelsstoredinDCT_quantizermatrix) :
% DCT_matrix=floor (DCT_matrix...
%./(DCT_quantizer (1: blocksize, 1: blocksize) * quant_multiple) + 0.5);
DCT_matrix_test=(DCT_matrix./(DCT_quantizer (1: blocksize, 1: blocksize) * quant_multiple));
DCT_matrix=round (DCT_matrix./(DCT_quantizer (1: blocksize, 1: blocksize) * quant_multiple));
% DCT_matrix=round (DCT_matrix);
% placeitintothecompressed - imagematrix:
Jpeg_img_test (col: row, row + blocksize - 1, col + blocksize - 1)=DCT_matrix_test;
Jpeg_img (col: row, row + blocksize - 1, col + blocksize - 1)=DCT_matrix;
End
End

% DCT figures
Figure (3); Hist (jpeg_img);
Figure (4); Imshow (jpeg_img);

Bitlength=1;
Orijpeg=jpeg_img;
For I=1: messagelength
For imbed=1:8
Messageshift=bitshift (message (I), 8 - imbed);
Showmess=uint8 (messageshift);
Showmess=bitshift (showmess, 7);
Messagebit (bitlength)=showmess;
Bitlength=bitlength + 1;
End
End

% embedding JSteg
i=1;
For row=1: rows
For col=1: cols
X=jpeg_img (row, col);
If (x=0 ~) && (x ~=1)
R=the mod (x, 2);
If r==0
If messagebit (I)==1
X=x + 1;
End
The else
If messagebit (I)==0
X=x - 1;
End
End
I=I + 1;
End
Jpeg_img (row, col)=x;
If I==bitlength
break;
End
End
If I==bitlength
break;
End
End
% jsteg hist
Figure (5); Hist (jpeg_img);
Orijpeg=orijpeg - jpeg_img;
% Reconstructing Image

Recon_img=coverzero - coverzero;

For row=1: blocksize: rows
For col=1: blocksize: cols
IDCT_matrix=jpeg_img (col: row, row + blocksize - 1, col + blocksize - 1);
IDCT_matrix=round (idct2 (IDCT_matrix. * (DCT_quantizer (1: blocksize, 1: blocksize) * quant_multiple)));
Recon_img (col: row, row + blocksize - 1, col + blocksize - 1)=IDCT_matrix;
End
End

Endrows=rows - pad_rows;
Cols=cols - pad_cols;
Recon_img=recon_img (1: rows, 1: cols);

figure(6); Imshow (recon_img);

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
Recon_img (1: rows, cols + extra_cols)=recon_img (1: rows, cols);
End

Cols=cols + pad_cols;

For extra_rows=1: pad_rows
Recon_img (rows + extra_rows, 1: cols)=recon_img (rows, 1: cols);
End

Rows=rows + pad_rows;

% coverzeroisnowpad_rowstaller

Jpeg_img=jpeg_img - jpeg_img;

For row=1: blocksize: rows
For col=1: blocksize: cols
DCT_matrix=recon_img (col: row, row + blocksize - 1, col + blocksize - 1);
DCT_matrix=dct2 (DCT_matrix); % % quantizeit (levelsstoredinDCT_quantizermatrix) : 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);
% placeitintothecompressed - imagematrix: jpeg_img (col: row, row + blocksize - 1, col + blocksize - 1)=DCT_matrix;
Jpeg_img (col: row, row + blocksize - 1, col + blocksize - 1)=DCT_matrix;
End
End

Stego=jpeg_img;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related