Created
March 26, 2020 07:55
-
-
Save THEFASHIONGEEK/4be0613dfc89d7b3ac3ea27b617ad0ab to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import cv2 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter5/sudoku.jpg", 0); | |
img = cv2.blur(img, (3, 3)); | |
# Otsu's thresholding | |
ret2,img = cv2.threshold(img,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) | |
# cv2.MORPH_OPEN | |
# cv2.morphologyEx | |
kernel_size = 3; | |
kernel = np.ones((kernel_size,kernel_size),np.uint8) | |
opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel) | |
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('opening Image'); | |
plt.imshow(opening, cmap = "gray"); | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment