Created
February 15, 2024 15:13
-
-
Save ritwikraha/74534c168784f90680ff734a3a8fdcf3 to your computer and use it in GitHub Desktop.
Mask_Dilation.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyM8jK716fultWhedClHWlVd", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/ritwikraha/74534c168784f90680ff734a3a8fdcf3/mask_dilation.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "5kX3hjY7Tqm3" | |
}, | |
"outputs": [], | |
"source": [ | |
"import cv2\n", | |
"import PIL\n", | |
"import matplotlib as plt\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# seg_mask = PIL.Image.open('image.jpg')\n", | |
"seg_mask = cv2.cvtColor(numpy.array(seg_mask), cv2.COLOR_RGB2BGR)" | |
], | |
"metadata": { | |
"id": "7o8R-vDrT7-u" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"kernel = np.ones((5, 5), np.uint8)\n", | |
"\n", | |
"seg_mask_dilated = cv2.dilate(img, kernel, iterations=3)" | |
], | |
"metadata": { | |
"id": "Sadm3fpCUJuI" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment