Skip to content

Commit 2a3ec9b

Browse files
authored
Merge pull request #1 from komal3120/master
erosion/dilation
2 parents f3c640d + f83d2cb commit 2a3ec9b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

Img_erosion_dilation.ipynb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 10,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"-1"
12+
]
13+
},
14+
"execution_count": 10,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
19+
"source": [
20+
"# Python program to demonstrate erosion and \n",
21+
"# dilation of images. \n",
22+
"import cv2 \n",
23+
"import numpy as np \n",
24+
"import matplotlib.pyplot as plt\n",
25+
" \n",
26+
"# Reading the input image \n",
27+
"img = cv2.imread('cameras-using-OpenCV.jpg', 0) \n",
28+
" \n",
29+
"# Taking a matrix of size 5 as the kernel \n",
30+
"kernel = np.ones((5,5), np.uint8) \n",
31+
" \n",
32+
"# The first parameter is the original image, \n",
33+
"# kernel is the matrix with which image is \n",
34+
"# convolved and third parameter is the number \n",
35+
"# of iterations, which will determine how much \n",
36+
"# you want to erode/dilate a given image. \n",
37+
"img_erosion = cv2.erode(img, kernel, iterations=1) \n",
38+
"img_dilation = cv2.dilate(img, kernel, iterations=1) \n",
39+
" \n",
40+
"cv2.imshow('Input', img) \n",
41+
"cv2.imshow('Erosion', img_erosion) \n",
42+
"cv2.imshow('Dilation', img_dilation) \n",
43+
"\n",
44+
"cv2.waitKey(0) "
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": []
53+
}
54+
],
55+
"metadata": {
56+
"kernelspec": {
57+
"display_name": "Python 3",
58+
"language": "python",
59+
"name": "python3"
60+
},
61+
"language_info": {
62+
"codemirror_mode": {
63+
"name": "ipython",
64+
"version": 3
65+
},
66+
"file_extension": ".py",
67+
"mimetype": "text/x-python",
68+
"name": "python",
69+
"nbconvert_exporter": "python",
70+
"pygments_lexer": "ipython3",
71+
"version": "3.7.6"
72+
}
73+
},
74+
"nbformat": 4,
75+
"nbformat_minor": 4
76+
}

Img_erosion_dilation_Output.png

203 KB
Loading

0 commit comments

Comments
 (0)