steganography (steganography): A technique and science for information hiding, that is, not letting anyone outside of the program know the delivery event of information (not just the content of the information)
1, randomly looking for two pictures
2, the use of Python implementation of the figure ctf.png hidden in figure 1539.jpg
Python:
fromPILImportImage fromSkimageImportColorImportNumPy as NPImportMatplotlib.pyplot as PltImportmathimg=np.array (Image.open ('1539.jpg')) Mark=np.array (Image.open ('Ctf.png')) Rows,cols,dims=Mark.shape forIinchRange (0,dims): forJinchRange (0,rows*2): forKinchRange (0,cols*2): Img[j,k,i]=img[j,k,i]&252 forIinchRange (0,dims): forJinchRange (0,rows): forKinchRange (0,cols): img[2*j,2*k,i]=img[2*j,2*k,i]+ (mark[j,k,i]&192)//64img[2*j,2*k+1,i]=img[2*j,2*k+1,i]+ (mark[j,k,i]&48)//16img[2*j+1,2*k,i]=img[2*j+1,2*k,i]+ (mark[j,k,i]&12)//4img[2*j+1,2*k+1,i]=img[2*j+1,2*k+1,i]+ (mark[j,k,i]&3) img=Image.fromarray (IMG) img.save ('C:\1539_with_ctf.png')
Have
3, extract the hidden figure from the figure 1539_with_ctf.png ctf.png
Python:
fromPILImportImage fromSkimageImportColorImportNumPy as NPImportMatplotlib.pyplot as PltImportMathimgwmark=np.array (Image.open (' 1539_with_ctf.png') ) Result=Imgwmarkrows,cols,dims=imgwmark.shaperows=rows//2cols=cols//2 forIinchRange (0,dims): forJinchRange (0,rows*2): forKinchRange (0,cols*2): Imgwmark[j,k,i]=imgwmark[j,k,i]&3 forIinchRange (0,dims): forJinchRange (0,rows): forKinchRange (0,cols): Result[j,k,i]=imgwmark[2*j,2*k,i]*64+imgwmark[2*j,2*k+1,i]*16 +imgwmark[2*j+1,2*k,i]*4+imgwmark[2*j+1,2*k+1, I]mark_get=Image.fromarray (Result) Mark_get.save ('Mark_get.png')
Have
Note: This code needs to use Python's pillow and skimage libraries, the Skimage library detailed installation See http://www.cnblogs.com/xdjun/p/7874794.html
----------------------------------------------------------------Split Line------------------------------------------------------ ---
PS: Meng New one, this article purely for study notes, in case a day silly forget--。 If there is something wrong, look at the big boys enlighten ~
Use Python for simple picture steganography