mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Co-authored-by: Kwabena W Agyeman <kwagyeman@users.noreply.github.com> Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
27 lines
665 B
Python
27 lines
665 B
Python
def unittest(data_path, temp_path):
|
|
import image
|
|
|
|
# Create test image with known distribution
|
|
img = image.Image(100, 100, image.GRAYSCALE)
|
|
|
|
# Fill with values 0-99 repeated
|
|
for y in range(100):
|
|
for x in range(100):
|
|
img.set_pixel(x, y, (x + y) % 100)
|
|
|
|
# Get histogram
|
|
hist = img.get_histogram()
|
|
|
|
# Get percentile (50th percentile should be around median)
|
|
percentile = hist.get_percentile(0.5)
|
|
|
|
# Verify percentile object
|
|
if not hasattr(percentile, 'value'):
|
|
return False
|
|
|
|
# 50th percentile should be around 50
|
|
if abs(percentile.value() - 50) > 20:
|
|
return False
|
|
|
|
return True
|