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