""" Test module for the ColorFeaturesPyramid class. This module contains unit tests to verify the functionality of the ColorFeaturesPyramid class, including initialization, down-sampling, and tile analysis. """ import os import sys import cv2 as cv import numpy as np # from avdb.db import DBOps, DBConnection from avdb.color_features_pyramid import ColorFeaturesPyramid def demo(): """ Main function to demonstrate the usage of the ColorFeaturesPyramid class. This function shows how to use the `_down_sample_and_analyze` method to perform down-sampling and tile analysis on an image. """ for img_name in ["TESTIMG", "IMG_9997", "IMG_9998", "IMG_9999", "IMG_2327"]: print(f"Processing image: {img_name}") # Example image path and UUID img_path = f"img/{img_name}/{img_name}.jpeg" uuid = img_name # Initialize the ColorFeaturesPyramid with custom parameters pyramid = ColorFeaturesPyramid( uuid=uuid, root_path=".", down_sampling=9, colorspace="lab" ) print("Starting down-sampling and analysis...") # Run the down-sampling and analysis process results = list(pyramid._down_sample_and_analyze()) # Print the results for each level for level, (histograms, metadata) in results: imgw, imgh, tilesw, tilesh = metadata print(f"Level {level}:") print(f" Image dimensions: {imgw} x {imgh}") print(f" Tiles: {tilesw} x {tilesh}") print(f" Histograms shape: {histograms.shape}") print() print("Down-sampling and analysis completed successfully.") if __name__ == "__main__": demo()