mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-08-09 04:12:42 +02:00
pil2cv: remove alpha, if any
This commit is contained in:
parent
e71923c684
commit
72f4a254af
1 changed files with 3 additions and 0 deletions
|
|
@ -10,6 +10,9 @@ def cv2pil(img):
|
|||
return Image.fromarray(np.array(cvtColor(img, COLOR_BGR2RGB)))
|
||||
|
||||
def pil2cv(img):
|
||||
if img.mode.endswith(('a', 'A')):
|
||||
# remove transparency (RGBA, LA, PA, and pre-multiplied variants)
|
||||
img = img.convert(img.mode[:-1])
|
||||
# from ocrd/workspace.py
|
||||
color_conversion = COLOR_GRAY2BGR if img.mode in ('1', 'L') else COLOR_RGB2BGR
|
||||
pil_as_np_array = np.array(img).astype('uint8') if img.mode == '1' else np.array(img)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue