Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Tests/test_imagemorph.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ def test_pattern_syntax_error(pattern: str) -> None:
lb.build_lut()


def test_build_default_lut() -> None:
lb = ImageMorph.LutBuilder(op_name="corner")
assert lb.build_default_lut() == lb.lut


def test_load_invalid_mrl() -> None:
# Arrange
invalid_mrl = "Tests/images/hopper.png"
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageMorph.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ def __init__(
def add_patterns(self, patterns: list[str]) -> None:
self.patterns += patterns

def build_default_lut(self) -> None:
def build_default_lut(self) -> bytearray:
symbols = [0, 1]
m = 1 << 4 # pos of current pixel
self.lut = bytearray(symbols[(i & m) > 0] for i in range(LUT_SIZE))
return self.lut

def get_lut(self) -> bytearray | None:
return self.lut
Expand Down
Loading