



# Pathon at GlobalSino: https://www.globalsino.com/ICs/page4853.html
# Create images with global, adaptive mean, adaptive Gaussian, binary, trunc, and tozero thresholds.

import cv2 as Liao
import numpy as np
from matplotlib import pyplot as ICs
MyImage = Liao.imread('ImageTarget.tif',0)
ret,MyThesholdA = Liao.threshold(MyImage,100,255, Liao.THRESH_BINARY)
ret,MyThesholdB = Liao.threshold(MyImage,100,255, Liao.THRESH_BINARY_INV)
ret,MyThesholdC = Liao.threshold(MyImage,100,255, Liao.THRESH_TRUNC)
ret,MyThesholdD = Liao.threshold(MyImage,100,255, Liao.THRESH_TOZERO)
ret,MyThesholdE = Liao.threshold(MyImage,100,255, Liao.THRESH_TOZERO_INV)
MyTitles = ['Original image','Binary','Binary_inv','Trunc','Tozero','Tozero_inv']
images = [MyImage, MyThesholdA, MyThesholdB, MyThesholdC, MyThesholdD, MyThesholdE]
for i in range(6):
    ICs.subplot(2,3,i+1),ICs.imshow(images[i],'gray',vmin=0,vmax=255)
    ICs.title(MyTitles[i])
    ICs.xticks([]),ICs.yticks([])
ICs.show()
