MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

digital_image_processing/dithering/burkes.py:19–37  ·  view source on GitHub ↗
(self, input_img, threshold: int)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 1

get_greyscaleMethod · 0.95

Tested by

no test coverage detected