python获取颜色范围
python获取颜色范围
img_src = Image.open('testluban.jpg') img_size=img_src.size; img_width=img_size[0]; img_height=img_size[1]; # 转换图片的模式为RGBA img_src = img_src.convert('RGB') # 获得文字图片的每个像素点 src_strlist = img_src.load() # 寻找图片中白色点 并且获得他的min max wattr=[]; hattr=[]; for w in range(img_width): for h in range(img_height): if src_strlist[w,h][0]>=240 and src_strlist[w,h][1]>=240 and src_strlist[w,h][2]>=240: wattr.append(w) hattr.append(h) print(min(wattr),min(hattr)) print(max(wattr),max(hattr))
如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/