Initial chromakey commit
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
data
|
data
|
||||||
.idea
|
.idea
|
||||||
|
output.png
|
||||||
23
chromakey.py
Normal file
23
chromakey.py
Normal 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')
|
||||||
Reference in New Issue
Block a user