img[r==r.max()] 是红色最深的点,怎么确定他们的坐标,python实现
时间: 2024-04-29 18:25:36 浏览: 38
假设img是一个3通道的RGB图像,可以使用如下代码来确定红色最深的点的坐标:
```python
import numpy as np
# 生成一个3通道的随机RGB图像
img = np.random.randint(0, 255, size=(100, 100, 3), dtype=np.uint8)
# 找到红色最深的点的坐标
r, _, _ = cv2.split(img)
row, col = np.where(r == r.max())
# 输出红色最深的点的坐标
print(row, col)
```
解释:首先使用cv2.split函数将RGB图像分离成三个通道,然后取出红色通道r。接着使用numpy的where函数找到红色最深的点的坐标,最后输出坐标值。
阅读全文
相关推荐







