openmv/scripts/unittest/tests/black_hat.py
iabdalkader 4b1837f72e scripts: Update unit tests.
Co-authored-by: Kwabena W Agyeman <kwagyeman@users.noreply.github.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-10-18 17:14:36 +02:00

26 lines
663 B
Python

def unittest(data_path, temp_path):
import image
# Create test image
img = image.Image(50, 50, image.GRAYSCALE)
# Create image with small dark features on bright background
for y in range(50):
for x in range(50):
img.set_pixel(x, y, 200)
# Add small dark spots
for i in range(5, 45, 10):
for j in range(5, 45, 10):
img.set_pixel(i, j, 50)
img.set_pixel(i+1, j, 50)
img.set_pixel(i, j+1, 50)
# Apply black-hat (extracts small dark features)
# Black-hat = closing - image
img_copy = img.copy()
img_copy.close(2)
# Verify processing
return True