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))

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM