Skip to content

Instantly share code, notes, and snippets.

@THEFASHIONGEEK
Created March 26, 2020 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save THEFASHIONGEEK/b7833b34e5ca8a2435b2a84b8e04fe77 to your computer and use it in GitHub Desktop.
Save THEFASHIONGEEK/b7833b34e5ca8a2435b2a84b8e04fe77 to your computer and use it in GitHub Desktop.
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/a.jpg", 0);
img = cv2.resize(img, (256, 256));
ret,img = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
kernel = np.ones((11,11),np.uint8)
eroded = cv2.erode(img,kernel,iterations = 1)
f = plt.figure(figsize=(15,15))
f.add_subplot(1, 2, 1).set_title('Original Image');
plt.imshow(img, cmap = "gray")
f.add_subplot(1, 2, 2).set_title('Eroded Image');
plt.imshow(eroded, cmap = "gray");
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment