Python提问,Python如何提取图片像素点坐标值?。给个代码例子,各位!
可以用numpy的column_stack和where函数来获取像素点在某阈值范围内的坐标。例子:
import numpy as np
from PIL import Image
image = Image.open("tqc.jpg")
pixels = np.asarray(image)
# Set threshold level
threshold_level = 50
# Find coordinates of all pixels below threshold
coords = np.column_stack(np.where(pixels < threshold_level))
print(coords)
如果对你有帮助,请点击我回答的右上角采纳按钮给予采纳。
可以用opencv获取像素点的rgb值(pip install opencv-python)
有帮助麻烦点个采纳【本回答右上角】,谢谢~~
import cv2
# 读取图像
img = cv2.imread("edge.jpg")
# 查看 (10,10) 位置的RGB
# 注意:此处返回顺序为 [B, G, R]
print(img[10,10])
https://blog.csdn.net/weixin_39968266/article/details/110371905 https://blog.csdn.net/weixin_39968266/article/details/110371905
https://blog.csdn.net/guaiderzhu1314/article/details/104468200 https://blog.csdn.net/guaiderzhu1314/article/details/104468200
参考这两个链接,或许可以实现获取图像像素点坐标的要求
如果有用,点击右上角采纳哦~