Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions digital_image_processing/dithering/burkes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ def __init__(self, input_img, threshold: int):
def get_greyscale(cls, blue: int, green: int, red: int) -> float:
"""
>>> Burkes.get_greyscale(3, 4, 5)
3.753
4.185
"""
return 0.114 * blue + 0.587 * green + 0.2126 * red
return 0.114 * blue + 0.587 * green + 0.299 * red
Copy link
Contributor

@tianyizheng02 tianyizheng02 Jul 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to Internet, it's either (0.2126R + 0.7152G + 0.0722B) or (0.299R + 0.587G + 0.114B)

Could you add a source for these numbers so that we can avoid mistakes like this in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done :)


def process(self) -> None:
for y in range(self.height):
for x in range(self.width):
greyscale = int(self.get_greyscale(*self.input_img[y][x]))
if self.threshold > greyscale + self.error_table[y][x]:
self.output_img[y][x] = (0, 0, 0)
current_error = greyscale + self.error_table[x][y]
current_error = greyscale + self.error_table[y][x]
else:
self.output_img[y][x] = (255, 255, 255)
current_error = greyscale + self.error_table[x][y] - 255
current_error = greyscale + self.error_table[y][x] - 255
"""
Burkes error propagation (`*` is current pixel):

Expand Down