我正在做一个项目,在该项目中,我必须根据该屏幕的图像查找该屏幕的缺陷像素。现在,我已经使用opencv并为轮廓应用了蒙版,得到了屏幕区域以及缺陷像素。但是我被困在寻找缺陷像素的位置。为了找到我使用过的有缺陷的像素,红色是主要颜色:
现在,我需要找到未附加在“data_red”中和轮廓内的红色像素的位置。期待解决方案!预先感谢您。
红色= [i代表Image_data中的i]
为我穿红色衣服:
如果我> 175:
data_red.append(i)
The image before applying the mask, after applying the mask, only the red part remains red and others become black
现在,我需要显示不满足条件> 175的红色像素位置。
最佳答案
使用 Numpy 。
import numpy as np
# get red from somewhere
red_np = np.array(red)
data_red = red_np[red_np > 175]
# and for the ones not appended
not_appended = np.argwhere(data_red <= 175)
这将返回一个numpy数组,其数组data_red中所有元素的值均低于175。
关于python - 从Python的图片中获取所需的部分,然后找到该部分中的缺陷像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51381661/