(self, input_img, threshold: int)
| 17 | """ |
| 18 | |
| 19 | def __init__(self, input_img, threshold: int): |
| 20 | self.min_threshold = 0 |
| 21 | # max greyscale value for #FFFFFF |
| 22 | self.max_threshold = int(self.get_greyscale(255, 255, 255)) |
| 23 | |
| 24 | if not self.min_threshold < threshold < self.max_threshold: |
| 25 | msg = f"Factor value should be from 0 to {self.max_threshold}" |
| 26 | raise ValueError(msg) |
| 27 | |
| 28 | self.input_img = input_img |
| 29 | self.threshold = threshold |
| 30 | self.width, self.height = self.input_img.shape[1], self.input_img.shape[0] |
| 31 | |
| 32 | # error table size (+4 columns and +1 row) greater than input image because of |
| 33 | # lack of if statements |
| 34 | self.error_table = [ |
| 35 | [0 for _ in range(self.height + 4)] for __ in range(self.width + 1) |
| 36 | ] |
| 37 | self.output_img = np.ones((self.width, self.height, 3), np.uint8) * 255 |
| 38 | |
| 39 | @classmethod |
| 40 | def get_greyscale(cls, blue: int, green: int, red: int) -> float: |
nothing calls this directly
no test coverage detected