{"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 pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from pathlib import Path\nfrom PIL import Image\ninput_dir = Path(\"../input\")\ntest_dir = input_dir/'test_images'\ntrain_dir = input_dir/'train_images'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import random\nimport matplotlib.pyplot as plt\n#imgid=200021712-00019_2.jp\nrnd_nbr = random.randint(0,len(os.listdir(train_dir)))\nrnd_img_path = os.listdir(train_dir)[rnd_nbr]\n#on veut que l'image soit mutable donc on va faire un casting avec numpy\nrnd_img = np.array(Image.open(train_dir/rnd_img_path))\n#rnd_img = Image.open(train_dir/rnd_img_path)\nplt.figure(figsize=(30,10))\nplt.imshow(rnd_img, aspect='equal')\nprint(rnd_img_path)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#m=plt.imread(train_dir/rnd_img_path)\nm=rnd_img\nm.shape\nm1=m[2200:2500,200:500]\nplt.imshow(m1)\nx=np.mean(m)\nprint(x)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"\nnp.set_printoptions(threshold=np.inf)\nprint(m1)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#m1.setflags(write=1)\nm1[m1 > 120] = 250\nplt.imshow(m1)\nprint(m1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"m[m>130]=250\nplt.figure(figsize=(30,30))\nplt.imshow(m)","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":1}