新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:python如何讀取像素值
使用image模塊中的getpixel函數(shù)獲得像素值。

GetPixel函數(shù)檢索指定坐標(biāo)點(diǎn)的像素的RGB顏色值。
函數(shù)原型:
COLORREF GetPixel(HDC hdc, int nXPos, int nYPos)
參數(shù):
hdc:設(shè)備環(huán)境句柄。
nXPos:指定要檢查的像素點(diǎn)的邏輯X軸坐標(biāo)。
nYPos:指定要檢查的像素點(diǎn)的邏輯Y軸坐標(biāo)。
示例:
import Image import sys im = Image.open(sys.argv[1]) width = im.size[0] height = im.size[1] print "/* width:%d */"%(width) print "/* height:%d */"%(height) count = 0 for h in range(0, height): for w in range(0, width): pixel = im.getpixel((w, h)) for i in range(0,3): count = (count+1)%16 if (count == 0): print "0x%02x,/n"%(pixel[i]), else: print "0x%02x,"%(pixel[i]),
網(wǎng)站題目:創(chuàng)新互聯(lián)Python教程:python如何讀取像素值
文章分享:http://m.fisionsoft.com.cn/article/dhoegdg.html


咨詢(xún)
建站咨詢(xún)
