Image embedding-Large capacity information hiding algorithm

Source: Internet
Author: User

share a recent look at an algorithm for embedding hidden images:

"Large capacity information hiding algorithm", which is a kind of information hiding algorithm based on spatial domain Adaptive multi-plane bit. The algorithm has low computational complexity and large amount of information hiding. Experimental results show that the information hiding volume is larger than the LSB algorithm and has higher security without affecting the image visual effect. The main idea of the algorithm is to judge each pixel point, based on the HVS characteristics, the specified bit (y) after the highest non-0 significant bit is embedded in the hidden information and embedded in another point (Z).

The following is directly affixed to the MATLAB code and experimental results:

(1) MAIN_IMGEMBED.M

Clc;clear All;close all;warning off all;yr=4;//The experiment gets yg=5;yb=3;img=imread (' lena.jpg '); Figure;imshow (Img,[]); title (' original image '); img=double (IMG); Imgr=img (:,:, 1); Imgg=img (:,:, 2); Imgb=img (:,:, 3); Imgmark=imread (' imgembed.jpg '); imgmark= Double (imgmark); Figure;imshow (imgmark,[]); title (' imgembed '); [Markm,markn]=size (Imgmark); imgmarkline = Imgmark (:);% two-dimensional array into a column imgmarklinebin=zeros (markm*markn*8,1);% converted to binary for II =1:MARKM*MARKN [Imgmarklinebin (8*ii-7), Imgmarklinebin (8*ii-6), Imgmarklinebin (8*ii-5), Imgmarklinebin (8*ii-4),        Imgmarklinebin (8*ii-3),...   Imgmarklinebin (8*ii-2), Imgmarklinebin (8*ii-1), Imgmarklinebin (8*ii)]=find8bits (Imgmarkline (ii)); end%%% embedded% for red channel embednumsed=0;% embedded number [M,n,z]=size (IMG); Y=zeros (8,1); flag=0;    % Auxiliary Jumping Mark imgrline=imgr (:);% converted to a column of imgrlinenew=imgrline;% embedded for ii=1:m*n if flag==1;% jumps out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (Imgrline (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yr; %Can embed the number if embednums>0% conforms to the embedding condition for jj=1:embednums embednumsed=embednumsed+1; % embedded number if embednumsed>markm*markn*8% embedded complete flag=1;            % set the label so that the outer loop also jumps out of break; End Y (JJ) =imgmarklinebin (embednumsed);% embedded End end Imgrlinenew (ii) =bin2dec_trans (y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)),% embedded Endimgr2=reshape (imgrlinenew,[m,n]),% for G-Channel imggline=imgg (:); Convert to a column of imgglinenew=imggline; % embedded after for ii=1:m*n if flag==1;    % jump out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (Imggline (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yg; % can embed the number if embednums>0% conforms to the embedding condition for jj=1:embednums embednumsed=embednumsed+1; % embedded number if embednumsed>markm*markn*8% embedded complete flag=1;            % set the label so that the outer loop also jumps out of break; End Y (JJ) =imgmarklinebin (embednumsed);% embedded End end Imgglinenew (ii) =bin2dec_trans (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1));% embedded E Ndimgg2=reshape (Imgglinenew,[m,n]);% for B-Channel IMGBLINE=IMGB (:);% converted to a column of imgblinenew=imgbline;% embedded for ii=1:m*n if flag==1;    % jump out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (Imgbline (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yb; % can embed the number if embednums>0% conforms to the embedding condition for jj=1:embednums embednumsed=embednumsed+1; % embedded number if embednumsed>markm*markn*8% embedded complete flag=1;            % set the label so that the outer loop also jumps out of break; End Y (JJ) =imgmarklinebin (embednumsed);% embedded End end Imgblinenew (ii) =bin2dec_trans ( Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)),% embedded Endimgb2=reshape (Imgblinenew,[m,n]), Imgnew=zeros (m,n,z); Imgnew (: ,:, 1) =imgr2;imgnew (:,:, 2) =imgg2;imgnew (:,:, 3) =imgb2;figure;imshow (Uint8 (Imgnew), []); title (' Embedded RGB graph ');% Imwrite (Uint8 (imgnew), ' media picture _ embedded image after. jpg '); % Save Picture%%% extract embedded Image Flag=0;imgmark_extractlinebin=zeros (markm*markn*8,1); extractnumsed=0;% has extracted the number of R channels IMGRLINE2=IMGR2 ( :); % converted to a column for ii=1:m*n if flag==1;    % jump out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (ImgRline2 (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yr; % has embedded the number if embednums>0% conforms to the embedding condition for jj=1:embednums extractnumsed=extractnumsed+1; % has been extracted if extractnumsed>markm*markn*8% is completed flag=1;            % set the label so that the outer loop also jumps out of break; End Imgmark_extractlinebin (extractnumsed) =y (JJ);% extract end end end% g Channel IMGGLINE2=IMGG2 (:) ; % converted to a column for ii=1:m*n if flag==1;    % jump out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (ImgGline2 (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yg;  % Number of embedded  If embednums>0% complies with the embedding condition for jj=1:embednums extractnumsed=extractnumsed+1; % has been extracted if extractnumsed>markm*markn*8% is completed flag=1;            % set the label so that the outer loop also jumps out of break; End Imgmark_extractlinebin (extractnumsed) =y (JJ);% extract end end end% g Channel Imgbline2=imgb2 (:) ; % converted to a column for ii=1:m*n if flag==1;    % jump out of outer loop break;       End [Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)]=find8bits (ImgBline2 (ii));    Posnzreo=findnotzero (Y (8), Y (7), Y (6), Y (5), Y (4), Y (3), Y (2), Y (1)); Embednums=posnzreo-yb; % has embedded the number if embednums>0% conforms to the embedding condition for jj=1:embednums extractnumsed=extractnumsed+1; % has been extracted if extractnumsed>markm*markn*8% is completed flag=1;            % set the label so that the outer loop also jumps out of break; End Imgmark_extractlinebin (extractnumsed) =y (JJ);% extract end end end% binary goto decimal imgmarklinedec= Zeros (markm*markn,1); % conversion to decimal for Ii=1:marKM*MARKN Imgmarklinedec (ii) =bin2dec_trans (Imgmark_extractlinebin (8*ii-7), Imgmark_extractlinebin (8*ii-6), Imgmark                                     _extractlinebin (8*ii-5), Imgmark_extractlinebin (8*ii-4),... Imgmark_extractlinebin (8*ii-3), Imgmark_extractlinebin (8*ii-2), Imgmark_extractlinebin (8*ii-1), Imgmark_ Extractlinebin (8*II)); Endimgmarkextract=reshape (Imgmarklinedec,[markm,markn]); Figure;imshow (Imgmarkextract,[]) Title (' Extracted embedded image ');% Imwrite (Uint8 (imgmarkextract), ' pending image _gray_ extract result. jpg '); % Save picture% Check to extract the difference between the watermark and the original Watermark Difmarked=imgmarkextract-imgmark; % do difference% found difference of 0, that is to explain exactly the same, extract the correct

(2) find8bits.m

function [Y7,y6,y5,y4,y3,y2,y1,y0]=find8bits (Data) y0=mod (data,2); Y7=fix (data/128);D Ata=data-y7*128;y6=fix (Data/ 64); Data=data-y6*64;y5=fix (DATA/32); Data=data-y5*32;y4=fix (DATA/16); Data=data-y4*16;y3=fix (DATA/8);  Data=data-y3*8;y2=fix (DATA/4);  Data=data-y2*4;y1=fix (DATA/2);  Data=data-y1*2;end

 

(3) BIN2DEC_TRANS.M

% binary goto decimal function Data=bin2dec_trans (y7,y6,y5,y4,y3,y2,y1,y0)   data=y7*128+y6*64+y5*32+y4*16+y3*8+y2*4+y1*2+ Y0;end

  

(4) Findnotzero.m

% to find the first nonzero digit from the highest bit (eighth bit) Start function Posnzreo=findnotzero (y7,y6,y5,y4,y3,y2,y1,y0) if y7~=0      posnzreo=8;elseif y6~=0  posnzreo=7;elseif y5~=0  posnzreo=6;elseif y4~=0  posnzreo=5;elseif y3~=0  posnzreo=4;elseif y2~=0  posnzreo=3;elseif y1~=0  posnzreo=2;else          posnzreo=1;endend

  

The experimental results are as follows:

(1) Original

(2) to embed hidden images

(3) Media image embedded in hidden image

(4) Extracted embedded images

Download the entire project code to: http://download.csdn.net/download/tianma5/9508467

Caishuxueqian, a lot of advice.

Image embedding-Large capacity information hiding algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.