Last active
November 13, 2019 09:52
-
-
Save k-okawa/e875f00e3adfc2ba0c6e0aa3e2679675 to your computer and use it in GitHub Desktop.
画像を赤くする処理(OpenCV version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import sys | |
args = sys.argv | |
argc = len(args) | |
files = args[1:argc] | |
def convert_img(file): | |
img = Image.open(file) | |
size = img.size | |
for x in range(size[0]): | |
for y in range(size[1]): | |
r,g,b,a = img.getpixel((x,y)) | |
r = int((r + 255) / 2) | |
g = int(g * 0.5) | |
b = int(b * 0.5) | |
img.putpixel((x,y),(r,g,b,a)) | |
img.save(file,compress_level=9) | |
for file in files: | |
convert_img(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment