所以,我正在提取 JPG R , G 和 B 的像素值>图像,然后我使用三个通道计算一些索引。这给了我一个 numpy数组:Indice
这是我的代码:
import matplotlib.pyplot as plt
import numpy as np
import numpy
Image = plt.imread("/home/stagiaire/Bureau/image_mais_rgb.JPG")
blue = Image[:,:,0]
green = Image[:,:,1]
red= Image[:,:,2]
with np.errstate(divide='ignore'):
r = red / red + green + blue
g = green / red + green + blue
b = blue / red + green + blue
ExGRE = 2*g-r-b
ExRED = 1.4*r-b
Indice = ExGRE - ExRED
Indice_Image = Indice.astype(numpy.uint8)
现在我想将此图像数组转换为二值化图像并选择接近0(0.1或0.2)的阈值。我怎么能在 Python36 中做到这一点?