import cv2
import numpy as np 

# Load our new image
image = cv2.imread('images/Origin_of_Species.jpg',0)

cv2.imshow('Original', image)
cv2.waitKey(0)

# Value below 127 goes to 0 (black, everythig above goes to 255 (white)
ret, thresh1 = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY)
cv2.imshow('Threshold Binary', thresh1)
cv2.waitKey(0)

# It's good practice to blur images as it removes noise
image = cv2.GaussianBlur(image,(3,3),0)

# Using adaptiveThreshold
thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 3, 5)
cv2.imshow("Adaotive Mean Thresholding", thresh)
cv2.waitKey(0)

_, th2 = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Otsu's Thresholding", thresh)
cv2.waitKey(0)

# Otsu's thresholding after Gaussian filtering
blur = cv2.GaussianBlur(image, (5,5),0)
_,th3 = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Guassian Otsu's Thresholding", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()
19def59f50f7336e85248b18836034b99bdeb7f0
<mask token>

<mask token>
cv2.imshow('Original', image)
cv2.waitKey(0)
<mask token>
cv2.imshow('Threshold Binary', thresh1)
cv2.waitKey(0)
<mask token>
cv2.imshow('Adaotive Mean Thresholding', thresh)
cv2.waitKey(0)
<mask token>
cv2.imshow("Otsu's Thresholding", thresh)
cv2.waitKey(0)
<mask token>
cv2.imshow("Guassian Otsu's Thresholding", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

<mask token>
image = cv2.imread('images/Origin_of_Species.jpg', 0)
cv2.imshow('Original', image)
cv2.waitKey(0)
ret, thresh1 = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY)
cv2.imshow('Threshold Binary', thresh1)
cv2.waitKey(0)
image = cv2.GaussianBlur(image, (3, 3), 0)
thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.
    THRESH_BINARY, 3, 5)
cv2.imshow('Adaotive Mean Thresholding', thresh)
cv2.waitKey(0)
_, th2 = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Otsu's Thresholding", thresh)
cv2.waitKey(0)
blur = cv2.GaussianBlur(image, (5, 5), 0)
_, th3 = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Guassian Otsu's Thresholding", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

import cv2
import numpy as np
image = cv2.imread('images/Origin_of_Species.jpg', 0)
cv2.imshow('Original', image)
cv2.waitKey(0)
ret, thresh1 = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY)
cv2.imshow('Threshold Binary', thresh1)
cv2.waitKey(0)
image = cv2.GaussianBlur(image, (3, 3), 0)
thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.
    THRESH_BINARY, 3, 5)
cv2.imshow('Adaotive Mean Thresholding', thresh)
cv2.waitKey(0)
_, th2 = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Otsu's Thresholding", thresh)
cv2.waitKey(0)
blur = cv2.GaussianBlur(image, (5, 5), 0)
_, th3 = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Guassian Otsu's Thresholding", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

import cv2
import numpy as np 

# Load our new image
image = cv2.imread('images/Origin_of_Species.jpg',0)

cv2.imshow('Original', image)
cv2.waitKey(0)

# Value below 127 goes to 0 (black, everythig above goes to 255 (white)
ret, thresh1 = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY)
cv2.imshow('Threshold Binary', thresh1)
cv2.waitKey(0)

# It's good practice to blur images as it removes noise
image = cv2.GaussianBlur(image,(3,3),0)

# Using adaptiveThreshold
thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 3, 5)
cv2.imshow("Adaotive Mean Thresholding", thresh)
cv2.waitKey(0)

_, th2 = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Otsu's Thresholding", thresh)
cv2.waitKey(0)

# Otsu's thresholding after Gaussian filtering
blur = cv2.GaussianBlur(image, (5,5),0)
_,th3 = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow("Guassian Otsu's Thresholding", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()