【发布时间】:2018-07-13 08:04:38
【问题描述】:
您好,感谢您阅读我的问题!我注意到,当我尝试在使用“(b,g,r)= image [c,r]”更改像素值之前读取像素值时,python会跳过大部分像素吗?这有什么原因吗?有什么解决方法吗?我正在努力尝试增强图像中的任何红色,但如果 python 跳过像素,它将无法工作......
import argparse
import cv2
import numpy as np
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="Path to the image")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
for r in range(image.shape[1]):
for c in range(image.shape[0]):
count = count + 1
#without this line the code works fine but when it is included it
#skips most of the pixels...
(b,g,r) = image[c,r]
canvas[c, r] = (255, 255, 255)
cv2.imshow("changed canvas", canvas)
cv2.waitKey(0)
【问题讨论】:
-
你的迭代变量
r和红色通道变量r冲突,重命名一个。 -
谢谢!哇,不敢相信我错过了……
标签: python opencv computer-vision opencv3.0