This part of code apply gaussian blur before threshold
import cv2
from skimage.filters import threshold_minimum
from skimage.filters import gaussian
import matplotlib.pyplot as plt
img_gray = cv2.imread("comp2.PNG",0)
gau = gaussian(img_gray, 1,preserve_range=True)
thresh = threshold_minimum(gau)
binary = (img_gray > thresh)
fig, axes = plt.subplots()
plt.axis('off')
fig.add_subplot(1, 3, 1)
plt.imshow(img_gray)
plt.axis('off')
plt.title("original img")
fig.add_subplot(1,3,2)
plt.imshow(gau)
plt.axis('off')
plt.title("gaussian blur")
fig.add_subplot(1,3,3)
plt.imshow(binary)
plt.axis('off')
plt.title("threshold")
min threshold with gaussian blur
This part of code apply threshold before gaussian
import cv2
from skimage.filters import threshold_minimum
import matplotlib.pyplot as plt
img_gray = cv2.imread("comp2.PNG",0)
thresh = threshold_minimum(gau)
binary = (img_gray > thresh)
fig, axes = plt.subplots()
plt.axis('off')
fig.add_subplot(1, 2, 1)
plt.imshow(img_gray)
plt.axis('off')
plt.title("original img")
fig.add_subplot(1,2,2)
plt.imshow(binary)
plt.axis('off')
plt.title("threshold")
min threshold image without gauissian blur
These above codes are tried in jupyter lab. The following codes tried in python idle.
Opencv imshow()
in this part of code
import cv2
from skimage.filters import threshold_minimum
from skimage.filters import gaussian
import matplotlib.pyplot as plt
import numpy as np
img_gray = cv2.imread("comp2.PNG",0)
gau = gaussian(img_gray, 1,preserve_range=True)
thresh = threshold_minimum(gau)
binary = (img_gray > thresh)
binary = binary.astype(np.uint8) * 255
cv2.imshow("",binary)
cv2.waitKey(0)
cv2.destroyAllWindows()
Here is original image original image
I couldn't figure out why this happen. My goal is extract out white parts and apply corner detection to them. But when I apply gaussian filter there are unwanted parts too as seen in images. Using cv2 imshow()
give you unwanted result too. How can I achive getting just white part with opencv?
desired image