{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd \nimport matplotlib.pyplot as plt\nimport cv2","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":1.093403,"end_time":"2023-11-07T23:12:47.135387","exception":false,"start_time":"2023-11-07T23:12:46.041984","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-11-09T12:04:33.865036Z","iopub.execute_input":"2023-11-09T12:04:33.865454Z","iopub.status.idle":"2023-11-09T12:04:33.870816Z","shell.execute_reply.started":"2023-11-09T12:04:33.865423Z","shell.execute_reply":"2023-11-09T12:04:33.869710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def showImagesAndLabels(IMG_DIR, nImgToShow=10):\n    count = 0\n    for dirname, _, filenames in os.walk(IMG_DIR):\n        for filename in filenames:\n            image_path = os.path.join(dirname, filename)\n            label_path = image_path.replace('images','labels')\n            \n            try:\n                plt.figure(figsize=(7,3))\n                # Show the image\n                plt.subplot(1,3,1)\n                img = cv2.imread(image_path)\n                plt.imshow(img)\n                plt.title(image_path)\n                \n                # Show the mask\n                plt.subplot(1,3,2)\n                label = cv2.imread(label_path)\n                plt.imshow(label)\n                \n                # Show the image threshold\n                threshold = img.mean()\n                masked_image = cv2.threshold(img, threshold, 255, cv2.THRESH_BINARY)[1]\n                plt.subplot(1,3,3)\n                plt.imshow(masked_image)\n\n                count+=1\n            except:\n                pass\n\n            if count>nImgToShow:\n                break","metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-11-09T12:04:33.876595Z","iopub.execute_input":"2023-11-09T12:04:33.877462Z","iopub.status.idle":"2023-11-09T12:04:33.885557Z","shell.execute_reply.started":"2023-11-09T12:04:33.877430Z","shell.execute_reply":"2023-11-09T12:04:33.884747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"showImagesAndLabels('/kaggle/input/blood-vessel-segmentation/train/kidney_1_dense/images')","metadata":{"execution":{"iopub.status.busy":"2023-11-09T12:04:33.887588Z","iopub.execute_input":"2023-11-09T12:04:33.888166Z","iopub.status.idle":"2023-11-09T12:04:48.157293Z","shell.execute_reply.started":"2023-11-09T12:04:33.888124Z","shell.execute_reply":"2023-11-09T12:04:48.156559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"showImagesAndLabels('/kaggle/input/blood-vessel-segmentation/train/kidney_1_voi/images')","metadata":{"execution":{"iopub.status.busy":"2023-11-09T12:04:48.158353Z","iopub.execute_input":"2023-11-09T12:04:48.159229Z","iopub.status.idle":"2023-11-09T12:05:17.453930Z","shell.execute_reply.started":"2023-11-09T12:04:48.159199Z","shell.execute_reply":"2023-11-09T12:05:17.452845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"showImagesAndLabels('/kaggle/input/blood-vessel-segmentation/train/kidney_2/images')","metadata":{"execution":{"iopub.status.busy":"2023-11-09T12:05:17.455479Z","iopub.execute_input":"2023-11-09T12:05:17.455843Z","iopub.status.idle":"2023-11-09T12:05:32.898964Z","shell.execute_reply.started":"2023-11-09T12:05:17.455811Z","shell.execute_reply":"2023-11-09T12:05:32.897599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"showImagesAndLabels('/kaggle/input/blood-vessel-segmentation/train/kidney_3_sparse/images')","metadata":{"execution":{"iopub.status.busy":"2023-11-09T12:05:32.901236Z","iopub.execute_input":"2023-11-09T12:05:32.901590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# kidney_3_dense does not have images, only the masks","metadata":{}}]}