[英]Image Processing in python using PIL
我正在嘗試使用PIL在Python中進行一些圖像處理。 我需要舉一個標志,即圖片中有紅色。 有人可以給我一些指示嗎?
我認為可以在圖像上使用分割功能,並將其分割為各個通道。 此后,我不確定該怎么辦。
嘗試這樣的事情。 它遍歷每個像素,並檢查它是否是您想要的像素。
from PIL import Image
desired_colour = (255, 0, 0)
im = Image.open("myfile.jpg")
w, h = im.size
pix = im.load()
found = False
for i in range(w):
for j in range(h):
if pix[i, j] == desired_colour:
# Bingo! Found it!
found = True
break
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.