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

Method get_greyscale

digital_image_processing/dithering/burkes.py:40–54  ·  view source on GitHub ↗

>>> Burkes.get_greyscale(3, 4, 5) 4.185 >>> Burkes.get_greyscale(0, 0, 0) 0.0 >>> Burkes.get_greyscale(255, 255, 255) 255.0

(cls, blue: int, green: int, red: int)

Source from the content-addressed store, hash-verified

38
39 @classmethod
40 def get_greyscale(cls, blue: int, green: int, red: int) -> float:
41 """
42 >>> Burkes.get_greyscale(3, 4, 5)
43 4.185
44 >>> Burkes.get_greyscale(0, 0, 0)
45 0.0
46 >>> Burkes.get_greyscale(255, 255, 255)
47 255.0
48 """
49 """
50 Formula from https://en.wikipedia.org/wiki/HSL_and_HSV
51 cf Lightness section, and Fig 13c.
52 We use the first of four possible.
53 """
54 return 0.114 * blue + 0.587 * green + 0.299 * red
55
56 def process(self) -> None:
57 for y in range(self.height):

Callers 2

__init__Method · 0.95
processMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected