Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

erode dilate opencv python

# Python program to demonstrate erosion and
# dilation of images.
import cv2
import numpy as np
 
# Reading the input image
img = cv2.imread('input.png', 0)
 
# Taking a matrix of size 5 as the kernel
kernel = np.ones((5,5), np.uint8)
 
# The first parameter is the original image,
# kernel is the matrix with which image is
# convolved and third parameter is the number
# of iterations, which will determine how much
# you want to erode/dilate a given image.
img_erosion = cv2.erode(img, kernel, iterations=1)
img_dilation = cv2.dilate(img, kernel, iterations=1)
 
cv2.imshow('Input', img)
cv2.imshow('Erosion', img_erosion)
cv2.imshow('Dilation', img_dilation)
 
cv2.waitKey(0)
Comment

PREVIOUS NEXT
Code Example
Python :: mac install python 3.8 
Python :: how to split and keep delimiter at the same line in python 
Python :: get current date in python 
Python :: NameError: name ‘np’ is not defined 
Python :: python os make empty file 
Python :: opencv draw a point 
Python :: python rotate pdf pages 
Python :: Cannot convert non-finite values (NA or inf) to integer 
Python :: python how to generate random number in a range 
Python :: ValueError: cannot mask with array containing NA / NaN values 
Python :: pandas plotly backend 
Python :: add search field to django admin 
Python :: plot nan values sns 
Python :: dataframe find nan rows 
Python :: python check if variable is iterable 
Python :: sum number in a list python using recursion 
Python :: pygame draw circle 
Python :: pandas add dataframe to the bottom of another 
Python :: tkiner border 
Python :: flask get ip address of request 
Python :: numpy get index of nan 
Python :: python split string by tab 
Python :: How to perform run-length encoding in Python? 
Python :: if type is string python 
Python :: how to hit enter in selenium python 
Python :: print first dictionary keys python 
Python :: pygame change logo 
Python :: python check file format 
Python :: pandas select rows with values in a list 
Python :: celsius to fahrenheit in python 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =