{"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":"# 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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Importing libraries**","metadata":{}},{"cell_type":"code","source":"#GENERAL\nimport pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport random\n#PATH PROCESS\nimport os\nimport os.path\nfrom pathlib import Path\nimport glob\n#IMAGE PROCESS\nfrom PIL import Image\nimport cv2\n#IGNORING WARNINGS\nfrom warnings import filterwarnings\nfilterwarnings(\"ignore\",category=DeprecationWarning)\nfilterwarnings(\"ignore\", category=FutureWarning) \nfilterwarnings(\"ignore\", category=UserWarning)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:41.956325Z","iopub.execute_input":"2022-07-16T14:50:41.957216Z","iopub.status.idle":"2022-07-16T14:50:43.480039Z","shell.execute_reply.started":"2022-07-16T14:50:41.957059Z","shell.execute_reply":"2022-07-16T14:50:43.479132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Paths**","metadata":{}},{"cell_type":"code","source":"# adding paths\n\nDATA_DIR = \"/kaggle/input/hubmap-organ-segmentation\"\n\nTrain_Data_Path = Path(\"../input/hubmap-organ-segmentation/train_images\")\nTest_Data_Path = Path(\"../input/hubmap-organ-segmentation/test_images\")\nTrain_Annotation_Path = Path(\"../input/hubmap-organ-segmentation/train_annotations\")\n\nTrain_Tiff_Path = list(Train_Data_Path.glob(r\"*.tiff\"))\nTest_Tiff_Path = list(Test_Data_Path.glob(r\"*.tiff\"))\n\nTrain_Series = pd.Series(Train_Tiff_Path,name=\"Train\").astype(str)\nTest_Series= pd.Series(Test_Tiff_Path,name=\"Train\").astype(str)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:47.048787Z","iopub.execute_input":"2022-07-16T14:50:47.049147Z","iopub.status.idle":"2022-07-16T14:50:47.098659Z","shell.execute_reply.started":"2022-07-16T14:50:47.049118Z","shell.execute_reply":"2022-07-16T14:50:47.097814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#reading csv files \n\nTRAIN_CSV = os.path.join(DATA_DIR, \"train.csv\")\nTrain_df = pd.read_csv(TRAIN_CSV)\n\nTEST_CSV = os.path.join(DATA_DIR, \"test.csv\")\nTest_df = pd.read_csv(TEST_CSV)\n\nSubmission_CSV   = os.path.join(DATA_DIR, \"sample_submission.csv\")\nsubmission_df = pd.read_csv(Submission_CSV)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:50.433148Z","iopub.execute_input":"2022-07-16T14:50:50.433630Z","iopub.status.idle":"2022-07-16T14:50:50.781481Z","shell.execute_reply.started":"2022-07-16T14:50:50.433586Z","shell.execute_reply":"2022-07-16T14:50:50.780199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **EDA**","metadata":{}},{"cell_type":"code","source":"train_df= pd.concat([Train_Series,\n                             Train_df],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:53.440552Z","iopub.execute_input":"2022-07-16T14:50:53.440931Z","iopub.status.idle":"2022-07-16T14:50:53.452590Z","shell.execute_reply.started":"2022-07-16T14:50:53.440900Z","shell.execute_reply":"2022-07-16T14:50:53.451523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:53:02.848857Z","iopub.execute_input":"2022-07-16T14:53:02.849252Z","iopub.status.idle":"2022-07-16T14:53:02.857812Z","shell.execute_reply.started":"2022-07-16T14:53:02.849223Z","shell.execute_reply":"2022-07-16T14:53:02.856339Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:55.231550Z","iopub.execute_input":"2022-07-16T14:50:55.231969Z","iopub.status.idle":"2022-07-16T14:50:55.259371Z","shell.execute_reply.started":"2022-07-16T14:50:55.231932Z","shell.execute_reply":"2022-07-16T14:50:55.258202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:50:58.072412Z","iopub.execute_input":"2022-07-16T14:50:58.076271Z","iopub.status.idle":"2022-07-16T14:50:58.085972Z","shell.execute_reply.started":"2022-07-16T14:50:58.076210Z","shell.execute_reply":"2022-07-16T14:50:58.084827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_df.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:00.399906Z","iopub.execute_input":"2022-07-16T14:51:00.400256Z","iopub.status.idle":"2022-07-16T14:51:00.410098Z","shell.execute_reply.started":"2022-07-16T14:51:00.400227Z","shell.execute_reply":"2022-07-16T14:51:00.408831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(train_df['organ'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:02.631225Z","iopub.execute_input":"2022-07-16T14:51:02.631580Z","iopub.status.idle":"2022-07-16T14:51:02.869875Z","shell.execute_reply.started":"2022-07-16T14:51:02.631550Z","shell.execute_reply":"2022-07-16T14:51:02.868739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['organ'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:16:54.476504Z","iopub.execute_input":"2022-07-16T15:16:54.476876Z","iopub.status.idle":"2022-07-16T15:16:54.485525Z","shell.execute_reply.started":"2022-07-16T15:16:54.476846Z","shell.execute_reply":"2022-07-16T15:16:54.484527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Inference:**\n\n99 images is of kidney & 93 of prostrate , followed by large intestine,spleen,lung.","metadata":{}},{"cell_type":"code","source":"sns.countplot(train_df['sex'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:05.159428Z","iopub.execute_input":"2022-07-16T14:51:05.159846Z","iopub.status.idle":"2022-07-16T14:51:05.264724Z","shell.execute_reply.started":"2022-07-16T14:51:05.159810Z","shell.execute_reply":"2022-07-16T14:51:05.263899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['sex'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:16:02.561941Z","iopub.execute_input":"2022-07-16T15:16:02.562647Z","iopub.status.idle":"2022-07-16T15:16:02.573613Z","shell.execute_reply.started":"2022-07-16T15:16:02.562602Z","shell.execute_reply":"2022-07-16T15:16:02.572699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Inference:**\n\n Male images 229 & of female images is 122","metadata":{}},{"cell_type":"code","source":"train_df['img_width'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:07.990852Z","iopub.execute_input":"2022-07-16T14:51:07.991234Z","iopub.status.idle":"2022-07-16T14:51:08.001864Z","shell.execute_reply.started":"2022-07-16T14:51:07.991205Z","shell.execute_reply":"2022-07-16T14:51:08.000922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['img_height'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:43.414290Z","iopub.execute_input":"2022-07-16T14:51:43.415078Z","iopub.status.idle":"2022-07-16T14:51:43.424870Z","shell.execute_reply.started":"2022-07-16T14:51:43.415032Z","shell.execute_reply":"2022-07-16T14:51:43.423853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Inference:**\n\n out of 351 images 326 are of 3000X3000 size\n\n     ","metadata":{}},{"cell_type":"code","source":"sns.countplot(x = train_df['organ'], hue=train_df['sex'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:51:52.624277Z","iopub.execute_input":"2022-07-16T14:51:52.624645Z","iopub.status.idle":"2022-07-16T14:51:52.829959Z","shell.execute_reply.started":"2022-07-16T14:51:52.624616Z","shell.execute_reply":"2022-07-16T14:51:52.829206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(x = train_df['age'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:52:02.559824Z","iopub.execute_input":"2022-07-16T14:52:02.560253Z","iopub.status.idle":"2022-07-16T14:52:02.785303Z","shell.execute_reply.started":"2022-07-16T14:52:02.560218Z","shell.execute_reply":"2022-07-16T14:52:02.784223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Inference:**\n\nAge distribution shows more images are between 60-80 years of age.","metadata":{}},{"cell_type":"code","source":"sns.countplot(train_df['data_source'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T14:52:10.415501Z","iopub.execute_input":"2022-07-16T14:52:10.415928Z","iopub.status.idle":"2022-07-16T14:52:10.575830Z","shell.execute_reply.started":"2022-07-16T14:52:10.415892Z","shell.execute_reply":"2022-07-16T14:52:10.574618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Inference:**\n\nData source is HPA for all images","metadata":{}},{"cell_type":"markdown","source":"# **VISION PROCESS AND CONTROL**","metadata":{}},{"cell_type":"code","source":"def reading_tiff(image):\n    \n    Reading_Image = cv2.cvtColor(cv2.imread(image),cv2.COLOR_BGR2RGB)\n    \n    return Reading_Image","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:32:38.410800Z","iopub.execute_input":"2022-07-16T15:32:38.411182Z","iopub.status.idle":"2022-07-16T15:32:38.416614Z","shell.execute_reply.started":"2022-07-16T15:32:38.411149Z","shell.execute_reply":"2022-07-16T15:32:38.415802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def single_display_tiff(image):\n    \n    figure = plt.figure(figsize=(8,8))\n    Reading_Image = cv2.cvtColor(cv2.imread(image),cv2.COLOR_BGR2RGB)\n    \n    plt.xlabel(Reading_Image.shape)\n    plt.ylabel(Reading_Image.size)\n    plt.title(\"TIFF\")\n    plt.imshow(Reading_Image)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:29:50.171145Z","iopub.execute_input":"2022-07-16T15:29:50.172037Z","iopub.status.idle":"2022-07-16T15:29:50.178714Z","shell.execute_reply.started":"2022-07-16T15:29:50.171994Z","shell.execute_reply":"2022-07-16T15:29:50.177345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def different_type_display(image_one,image_two,image_three):\n    \n    figure,axis = plt.subplots(1,3,figsize=(10,12))\n    \n    axis[0].imshow(image_one)\n    axis[0].set_xlabel(image_one.shape)\n    axis[0].set_ylabel(image_one.size)\n    axis[0].set_title(\"image\")\n    axis[1].imshow(image_two)\n    axis[1].set_xlabel(image_two.shape)\n    axis[1].set_ylabel(image_two.size)\n    axis[1].set_title(\"adaptive threshold\")\n    axis[2].imshow(image_three)\n    axis[2].set_xlabel(image_three.shape)\n    axis[2].set_ylabel(image_three.size)\n    axis[2].set_title(\"canny_edge\")\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:30:03.083346Z","iopub.execute_input":"2022-07-16T15:30:03.084276Z","iopub.status.idle":"2022-07-16T15:30:03.093552Z","shell.execute_reply.started":"2022-07-16T15:30:03.084238Z","shell.execute_reply":"2022-07-16T15:30:03.092237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def threshold_display(image):\n    \n    figure = plt.figure(figsize=(8,8))\n    Reading_Image = cv2.cvtColor(cv2.imread(image),cv2.COLOR_BGR2RGB)\n    _,Threshold_Image = cv2.threshold(Reading_Image,30,255,cv2.THRESH_BINARY)\n    \n    plt.xlabel(Threshold_Image.shape)\n    plt.ylabel(Threshold_Image.size)\n    plt.title(\"THRESHOLD\")\n    plt.imshow(Threshold_Image)\n    \ndef threshold_reading(image):\n    \n    Reading_Image = cv2.cvtColor(cv2.imread(image),cv2.COLOR_BGR2RGB)\n    _,Threshold_Image = cv2.threshold(Reading_Image,30,255,cv2.THRESH_BINARY)\n    \n    return Threshold_Image","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def adaptive_threshold_display(image):\n    \n    figure = plt.figure(figsize=(8,8))\n    Reading_Image = cv2.imread(image,0)\n    Adaptive_Image = cv2.adaptiveThreshold(Reading_Image,20,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,9,2)\n    \n    plt.xlabel(Adaptive_Image.shape)\n    plt.ylabel(Adaptive_Image.size)\n    plt.title(\"ADAPTIVE_THRESHOLD\")\n    plt.imshow(Adaptive_Image)\n\ndef adaptive_threshold_reading(image):\n    \n    Reading_Image = cv2.imread(image,0)\n    Adaptive_Image = cv2.adaptiveThreshold(Reading_Image,20,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,9,2)\n    \n    return Adaptive_Image","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:31:32.146767Z","iopub.execute_input":"2022-07-16T15:31:32.147172Z","iopub.status.idle":"2022-07-16T15:31:32.155569Z","shell.execute_reply.started":"2022-07-16T15:31:32.147140Z","shell.execute_reply":"2022-07-16T15:31:32.154313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def canny_reading(image):\n    \n    Reading_Image = cv2.cvtColor(cv2.imread(image),cv2.COLOR_BGR2RGB)\n    Canny_Image = cv2.Canny(Reading_Image,5,100)\n    \n    return Canny_Image","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:31:46.105001Z","iopub.execute_input":"2022-07-16T15:31:46.105421Z","iopub.status.idle":"2022-07-16T15:31:46.111601Z","shell.execute_reply.started":"2022-07-16T15:31:46.105386Z","shell.execute_reply":"2022-07-16T15:31:46.110130Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Displaying Randomly 7 images from Training data:**","metadata":{}},{"cell_type":"code","source":"#Random display of images & image transformations\nimage_random_number=7\n\nfor i in range(image_random_number):\n    img=random.choice(Train_Tiff_Path)\n    print(img)\n    single_display_tiff(str(img))\n    different_type_display(reading_tiff(str(img)),\n                      adaptive_threshold_reading(str(img)),\n                      canny_reading(str(img)))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:32:44.146986Z","iopub.execute_input":"2022-07-16T15:32:44.148015Z","iopub.status.idle":"2022-07-16T15:33:14.767858Z","shell.execute_reply.started":"2022-07-16T15:32:44.147976Z","shell.execute_reply":"2022-07-16T15:33:14.766806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Displaying image from Test data:**","metadata":{}},{"cell_type":"code","source":"#Random display of images & image transformations\nsingle_display_tiff('../input/hubmap-organ-segmentation/test_images/10078.tiff')\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:33:37.579074Z","iopub.execute_input":"2022-07-16T15:33:37.579513Z","iopub.status.idle":"2022-07-16T15:33:38.593944Z","shell.execute_reply.started":"2022-07-16T15:33:37.579478Z","shell.execute_reply":"2022-07-16T15:33:38.593082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Image transformation of 10078.tiff\ndifferent_type_display(reading_tiff('../input/hubmap-organ-segmentation/test_images/10078.tiff'),\n                      adaptive_threshold_reading('../input/hubmap-organ-segmentation/test_images/10078.tiff'),\n                      canny_reading('../input/hubmap-organ-segmentation/test_images/10078.tiff'))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:33:48.514578Z","iopub.execute_input":"2022-07-16T15:33:48.515019Z","iopub.status.idle":"2022-07-16T15:33:50.284365Z","shell.execute_reply.started":"2022-07-16T15:33:48.514983Z","shell.execute_reply":"2022-07-16T15:33:50.283109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Displaying images with mask:**","metadata":{}},{"cell_type":"code","source":"#https://www.kaggle.com/code/pestipeti/decoding-rle-masks/notebook\ndef mask2rle(img):\n    '''\n    img: numpy array, 1 - mask, 0 - background\n    Returns run length as string formated\n    '''\n    pixels= img.T.flatten()\n    pixels = np.concatenate([[0], pixels, [0]])\n    runs = np.where(pixels[1:] != pixels[:-1])[0] + 1\n    runs[1::2] -= runs[::2]\n    return ' '.join(str(x) for x in runs)\n\n\ndef rle2mask(mask_rle, shape=(3000,3000)):\n    '''\n    mask_rle: run-length as string formated (start length)\n    shape: (width,height) of array to return \n    Returns numpy array, 1 - mask, 0 - background\n\n    '''\n    s = mask_rle.split()\n    starts, lengths = [np.asarray(x, dtype=int) for x in (s[0::2], s[1::2])]\n    starts -= 1\n    ends = starts + lengths\n    img = np.zeros(shape[0]*shape[1], dtype=np.uint8)\n    for lo, hi in zip(starts, ends):\n        img[lo:hi] = 1\n    return img.reshape(shape).T","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:35:16.017988Z","iopub.execute_input":"2022-07-16T15:35:16.018489Z","iopub.status.idle":"2022-07-16T15:35:16.032217Z","shell.execute_reply.started":"2022-07-16T15:35:16.018444Z","shell.execute_reply":"2022-07-16T15:35:16.031225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"organs = np.unique(train_df.organ)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:35:18.624644Z","iopub.execute_input":"2022-07-16T15:35:18.625363Z","iopub.status.idle":"2022-07-16T15:35:18.631483Z","shell.execute_reply.started":"2022-07-16T15:35:18.625320Z","shell.execute_reply":"2022-07-16T15:35:18.630070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/code/tarandeep97/initial-eda-and-visualization\nfig, ax = plt.subplots(1,len(organs),figsize=(20,20))\n\nfor i in range(len(organs)):\n    organ_df = train_df[train_df['organ']==organs[i]].reset_index()\n    idx = np.random.randint(organ_df.shape[0])\n    image = plt.imread(f\"{DATA_DIR}/train_images/{organ_df.id[idx]}.tiff\")\n    mask = rle2mask(organ_df.rle[idx],shape=(organ_df.img_height[idx],organ_df.img_width[idx]))\n    ax[i].imshow(image)\n    ax[i].imshow(mask,alpha=0.4)\n    ax[i].set_title(organ_df.organ[idx])\n    ax[i].axis(\"off\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:35:22.097016Z","iopub.execute_input":"2022-07-16T15:35:22.097372Z","iopub.status.idle":"2022-07-16T15:35:34.185383Z","shell.execute_reply.started":"2022-07-16T15:35:22.097344Z","shell.execute_reply":"2022-07-16T15:35:34.183969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Visualize mask + image : to scale down images we can also resize shape with scaling factor as well\nfig, ax = plt.subplots(1,len(organs),figsize=(20,20))\n\nfor i in range(len(organs)):\n    organ_df = train_df[train_df['organ']==organs[i]].reset_index()\n    idx = np.random.randint(organ_df.shape[0])\n    image = plt.imread(f\"{DATA_DIR}/train_images/{organ_df.id[idx]}.tiff\")\n    mask = rle2mask(organ_df.rle[idx],shape=(organ_df.img_height[idx],organ_df.img_width[idx]))\n    image=np.mean(image,axis=2)\n    #scale=2\n    #new_size = (image.shape[1] // scale, image.shape[0] // scale)\n    #image = cv2.resize(image, new_size)\n    #mask = cv2.resize(mask, new_size)\n    Blend_Image = cv2.addWeighted(image,0.8,mask,0.4,0.5,image,cv2.CV_32F)\n    ax[i].imshow(Blend_Image)\n    ax[i].imshow(mask,alpha=0.4)\n    ax[i].set_title(organ_df.organ[idx])\n    ax[i].axis(\"off\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T15:36:32.531234Z","iopub.execute_input":"2022-07-16T15:36:32.531617Z","iopub.status.idle":"2022-07-16T15:36:45.053089Z","shell.execute_reply.started":"2022-07-16T15:36:32.531586Z","shell.execute_reply":"2022-07-16T15:36:45.051932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Thank you for reading !\n# If you like or find it useful please do upvote!!!\n","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}