Initial chromakey commit

This commit is contained in:
Ian Gulliver
2024-08-11 14:13:41 -07:00
parent cb0f779a39
commit 81a9fd5fb8
2 changed files with 25 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
data
.idea
.idea
output.png

23
chromakey.py Normal file
View File

@@ -0,0 +1,23 @@
import os
import rawpy
from PIL import Image, ImageOps
path = 'data/RAW/SC1/BR1'
filename = os.path.join(path, '00570/back.orf')
raw = rawpy.imread(filename)
rgb_image = raw.postprocess()
image = Image.fromarray(rgb_image).convert('RGBA')
hsv_image = image.convert('HSV')
h, s, v = hsv_image.split()
green_mask = Image.eval(h, lambda x: 255 if 50 < x < 90 else 0)
green_mask = ImageOps.invert(green_mask)
rgba_image = image.copy()
rgba_image.putalpha(green_mask)
rgba_image.save('output.png', 'PNG')