{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np\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":"! git clone https://github.com/dwgoon/jpegio","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"\n!pip install jpegio/.\nimport jpegio as jio\n\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)[:20]\nimgList[0]=\"00004.jpg\"\nfor imgIdx in range(1): \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    c_struct=jio.read(coverDir + imgList[imgIdx])\n    coverDCT = np.zeros([512,512,3])\n    coverDCT[:,:,0] = c_struct.coef_arrays[0]\n    coverDCT[:,:,1] = c_struct.coef_arrays[1]\n    coverDCT[:,:,2] = c_struct.coef_arrays[2]\n    coverQTbl = c_struct.quant_tables[0];\n    plt.imshow( abs(coverDCT) )\n    plt.show()\n    print(coverQTbl)\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];\n    imgDiff = coverDCT - stegoDCT;\n    NbChanges = np.sum( abs( imgDiff ) )\n    plt.imshow( abs(imgDiff) )\n    plt.show()\n    print(stegoQTbl)\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    print(stegoQTbl)\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    print(stegoQTbl)\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\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}