Python提问,Python如何提取图片像素点坐标值?。给个代码例子,各位!
3条回答 默认 最新
- CSDN专家-HGJ 2021-08-08 14:19关注
可以用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)
如果对你有帮助,请点击我回答的右上角采纳按钮给予采纳。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 4无用