Spaces:
Sleeping

File size: 823 Bytes
9598e21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Képfelosztó modul két játékos módhoz.
1 képet 2 részre oszt (bal és jobb fél), középen vágva.
TODO: ez lehetne ettől intelligensebb, elkerülve a vakon vágást
"""

from typing import List
import numpy as np
from core.base_processor import PreprocessingModule
from core import DataObject
from constraints import TypeConstraint


class ImageSplitterModule(PreprocessingModule):

    def __init__(self):
        super().__init__(name="ImageSplitter")
        self.add_constraint(TypeConstraint(np.uint8))

    def _process(self, input: DataObject) -> List[DataObject]:
        image = input.data
        width = image.shape[1]
        mid_point = width // 2

        left_half = image[:, :mid_point]
        right_half = image[:, mid_point:]

        return [DataObject(left_half), DataObject(right_half)]