{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Resources Used\n* [Image Pre-processing](http://towardsdatascience.com/image-pre-processing-c1aec0be3edf)\n* [Image Filtering](https://medium.com/towards-artificial-intelligence/image-filtering-dfe29581f859)\n* [Loading images in Keras for CNN from directory but label in CSV file](https://stackoverflow.com/questions/59464409/loading-images-in-keras-for-cnn-from-directory-but-label-in-csv-file)","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport os\nfrom PIL import Image\nimport openslide","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_img_path = \"/kaggle/input/prostate-cancer-grade-assessment/train_images\"\nlabel_path = \"/kaggle/input/prostate-cancer-grade-assessment/train_label_masks\"\n\ntrain_img = [img for img in os.listdir(train_img_path)]\ntrain_label = [label for label in os.listdir(label_path)]\n\ntrain_img = list(sorted(train_img))\ntrain_label = list(sorted(train_label))\n\nSIZE = 200\n\ndef preprocessing_img(img):\n    slide = openslide.OpenSlide(img)\n    img = np.array(slide.get_thumbnail(size=(SIZE, SIZE)))\n    img = Image.fromarray(img)\n    img = img.resize((SIZE, SIZE))\n    img = np.array(img)\n    return img\n\nimg_array = []\nfor i in range(10):\n    img = train_img_path + \"/\" + train_img[i]\n    img = preprocessing_img(img)\n    img_array.append(img)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Image Processing","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.imshow(img_array[0])","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}