Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def toAlphaBlackWhite(blackImg, whiteImg):
- size = blackImg.size
- blackImg = blackImg.convert('RGBA')
- whiteImg = whiteImg.convert('RGBA')
- loadedBlack = blackImg.load()
- loadedWhite = whiteImg.load()
- for x in range(size[0]):
- for y in range(size[1]):
- blackPixel = loadedBlack[x, y]
- whitePixel = loadedWhite[x, y]
- loadedBlack[x, y] = (
- int((blackPixel[0] + whitePixel[0]) / 2),
- int((blackPixel[1] + whitePixel[1]) / 2),
- int((blackPixel[2] + whitePixel[2]) / 2),
- int(255 - 255 * getBrightness(whitePixel) - getBrightness(blackPixel))
- )
- return blackImg
Add Comment
Please, Sign In to add comment