Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Matplotlib中的图像处理_Python_Numpy_Matplotlib_Computer Vision - Fatal编程技术网

Python Matplotlib中的图像处理

Python Matplotlib中的图像处理,python,numpy,matplotlib,computer-vision,Python,Numpy,Matplotlib,Computer Vision,这是一个有点幼稚的问题,但我对数据科学是新手,所以这个问题。 我正在学习一门课程,它读取2D图像并执行以下操作 image = mpimg.imread('test.jpg') duplicate = np.copy(image) red_threshold = green_threshold = blue_threshold = 0 rgb_threshold = [red_threshold, green_threshold, blue_threshold] 特别是这条线 threshol

这是一个有点幼稚的问题,但我对数据科学是新手,所以这个问题。 我正在学习一门课程,它读取2D图像并执行以下操作

image = mpimg.imread('test.jpg')
duplicate = np.copy(image)
red_threshold = green_threshold = blue_threshold = 0
rgb_threshold = [red_threshold, green_threshold, blue_threshold]
特别是这条线

thresholds = (image[:,:,0] < rgb_threshold[0]) | (image[:,:,1] < rgb_threshold[1]) | (image[:,:,2] < rgb_threshold[2])
duplicate[thresholds] = [0,0,0]
thresholds=(图像[:,:,0]
这行代码的解释是

结果“复制”是一个图像,其中的像素位于 阈值已保留,低于阈值的像素已保留 停电了

我只是不明白怎么做? 有人能把这句话说清楚一点,帮我理解这里发生了什么吗?

上面的表达

thresholds = (image[:,:,0] < rgb_threshold[0]) | (image[:,:,1] < rgb_threshold[1]) | (image[:,:,2] < rgb_threshold[2])
这里第三个索引0是来自RGB的图像的通道,因此
图像[:,:,0],图像[:,:,1],图像[:,:,2]
分别是RGB通道s'像素

image[:,:,0] < rgb_threshold[0]) 
Out:

[26 55 47]

我建议使用最少的代表性数据,运行发布的代码,并分别进一步研究
|
的每个部分。这不是3D图像,而是带有3个通道的2D图像。有些软件将这样的图像表示为3D矩阵,但这并不能使其成为3D图像。@CrisLuengo已编辑并更正。无论如何,这个示例在我看来有点问题,您是从哪里复制粘贴的?
import numpy as np

a = np.array([26,0,46,])
b = np.array([0,55,1,])

print(a | b)
[26 55 47]