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

Method process

digital_image_processing/dithering/burkes.py:56–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

54 return 0.114 * blue + 0.587 * green + 0.299 * red
55
56 def process(self) -> None:
57 for y in range(self.height):
58 for x in range(self.width):
59 greyscale = int(self.get_greyscale(*self.input_img[y][x]))
60 if self.threshold > greyscale + self.error_table[y][x]:
61 self.output_img[y][x] = (0, 0, 0)
62 current_error = greyscale + self.error_table[y][x]
63 else:
64 self.output_img[y][x] = (255, 255, 255)
65 current_error = greyscale + self.error_table[y][x] - 255
66 """
67 Burkes error propagation (`*` is current pixel):
68
69 * 8/32 4/32
70 2/32 4/32 8/32 4/32 2/32
71 """
72 self.error_table[y][x + 1] += int(8 / 32 * current_error)
73 self.error_table[y][x + 2] += int(4 / 32 * current_error)
74 self.error_table[y + 1][x] += int(8 / 32 * current_error)
75 self.error_table[y + 1][x + 1] += int(4 / 32 * current_error)
76 self.error_table[y + 1][x + 2] += int(2 / 32 * current_error)
77 self.error_table[y + 1][x - 1] += int(4 / 32 * current_error)
78 self.error_table[y + 1][x - 2] += int(2 / 32 * current_error)
79
80
81if __name__ == "__main__":

Callers 2

test_burkesFunction · 0.95
burkes.pyFile · 0.45

Calls 1

get_greyscaleMethod · 0.95

Tested by 1

test_burkesFunction · 0.76