{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport random\nimport matplotlib.pyplot as plt\nimport glob\nimport os\nfrom PIL import Image \n\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"os.mkdir('./jpegio/')\n# Downloaded from https://github.com/dwgoon/jpegio\n# Author: Daewon Lee, github: @dwgoon\n# Wheel packaged for python 3.7\n!curl https://github.com/dwgoon/jpegio/blob/master/dist/jpegio-0.2.1-cp37-cp37m-linux_x86_64.whl > ./jpegio/jpegio-0.2.1-cp37-cp37m-linux_x86_64.whl\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Once downloaded install the package\n!pip install ./jpegio/jpegio-0.2.1-cp37-cp37m-linux_x86_64.whl\nimport jpegio as jio\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"\ncoverDir = \"/kaggle/input/alaska2-image-steganalysis/Cover/\"\nJMiPODDir = \"/kaggle/input/alaska2-image-steganalysis/JMiPOD/\"\nJUNIWARDDir = \"/kaggle/input/alaska2-image-steganalysis/JUNIWARD/\"\nUERDDir = \"/kaggle/input/alaska2-image-steganalysis/UERD/\"\n\ntrain_filenames = np.array(sorted(os.listdir(coverDir)))\ntrain_filenames[0:10]\n\n#imgList = sorted(os.listdir(coverDir))\nimgList = os.listdir(coverDir)\nrandom.shuffle(imgList)\nfor imgIdx in range( len(imgList) ): \n    c_struct=jio.read(coverDir + imgList[imgIdx] )\n    coverDCT = np.zeros([512,512,3]) ; coverDCT[:,:,0] = c_struct.coef_arrays[0] ; coverDCT[:,:,1] = c_struct.coef_arrays[1] ; coverDCT[:,:,2] = c_struct.coef_arrays[2]\n    coverQTbl = c_struct.quant_tables[0];\n    plt.imshow( abs(coverDCT) )\n    plt.show()\n\n    coverPixels = np.array( Image.open( os.path.join(coverDir , imgList[imgIdx] ) ) ).astype('float')\n    plt.imshow( coverPixels.astype('uint8') )\n    plt.show()\n\n\n    stego = jio.read( os.path.join( JMiPODDir , imgList[imgIdx] ) )\n    stegoDCT = np.zeros([512,512,3]) ; stegoDCT[:,:,0] = stego.coef_arrays[0] ; stegoDCT[:,:,1] = stego.coef_arrays[1] ; stegoDCT[:,:,2] = stego.coef_arrays[2]\n    stegoQTbl = stego.quant_tables[0]; #Of course this is the same as coverQTbl\n    imgDiff = coverDCT - stegoDCT;\n    NbChanges = np.sum( abs( imgDiff ) )\n    plt.imshow( abs(imgDiff) )\n    plt.show()\n    \n    stegoPixels = np.array( Image.open( os.path.join( JMiPODDir , imgList[imgIdx] ) ) ).astype('float')\n    pixelsDiff = coverPixels - stegoPixels;\n    plt.imshow( abs( pixelsDiff ) )\n    plt.show()\n    \n\n    stego = jio.read( os.path.join( JUNIWARDDir , imgList[imgIdx] ) )\n    stegoDCT = np.zeros([512,512,3]) ; stegoDCT[:,:,0] = stego.coef_arrays[0] ; stegoDCT[:,:,1] = stego.coef_arrays[1] ; stegoDCT[:,:,2] = stego.coef_arrays[2]\n    imgDiff = coverDCT - stegoDCT;\n    NbChanges = np.sum( abs( imgDiff ) )\n    plt.imshow( abs(imgDiff) )\n    plt.show()\n\n    stegoPixels = np.array( Image.open( os.path.join( JUNIWARDDir , imgList[imgIdx] ) ) ).astype('float')\n    pixelsDiff = coverPixels - stegoPixels;\n    plt.imshow( abs( pixelsDiff ) )\n    plt.show()\n\n\n    stego = jio.read( os.path.join( UERDDir , imgList[imgIdx] ) )\n    stegoDCT = np.zeros([512,512,3]) ; stegoDCT[:,:,0] = stego.coef_arrays[0] ; stegoDCT[:,:,1] = stego.coef_arrays[1] ; stegoDCT[:,:,2] = stego.coef_arrays[2]\n    imgDiff = coverDCT - stegoDCT;\n    NbChanges = np.sum( abs( imgDiff ) )\n    plt.imshow( abs(imgDiff) )\n    plt.show()\n\n    stegoPixels = np.array( Image.open( os.path.join( UERDDir , imgList[imgIdx] ) ) ).astype('float')\n    pixelsDiff = coverPixels - stegoPixels;\n    plt.imshow( abs( pixelsDiff ) )\n    plt.show()\n    \n    \n# Any results you write to the current directory are saved as output.\n","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":false},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4}