14 lines
481 B
Python
14 lines
481 B
Python
from PIL import Image
|
|
import numpy as np
|
|
def bands(img):
|
|
"""Top/bottom parchment frame heights as fractions (0,0 = full-art screen)."""
|
|
a=np.asarray(img.convert('RGB').resize((512,512)),float)
|
|
e=np.concatenate([a[:,:32],a[:,-32:]],1)
|
|
warm=(((e[:,:,0]-e[:,:,2])>25)&(e.mean(2)>35)).mean(1)>0.8
|
|
top=0
|
|
while top<200 and warm[top]: top+=1
|
|
bot=0
|
|
while bot<200 and warm[511-bot]: bot+=1
|
|
if top<20 or bot<20: return 0.0,0.0
|
|
return top/512, bot/512
|