MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / calculate_image_complexity

Function calculate_image_complexity

modules/icon_picture_processor.py:415–428  ·  view source on GitHub ↗

Compute image complexity (for picture vs icon). Returns (laplacian_variance, std_deviation).

(image_arr: np.ndarray)

Source from the content-addressed store, hash-verified

413
414# ======================== Image complexity ========================
415def calculate_image_complexity(image_arr: np.ndarray) -> tuple:
416 """Compute image complexity (for picture vs icon). Returns (laplacian_variance, std_deviation)."""
417 if image_arr.size == 0:
418 return 0.0, 0.0
419
420 gray = cv2.cvtColor(image_arr, cv2.COLOR_BGR2GRAY)
421
422 # Laplacian variance (texture/edge)
423 laplacian_var = cv2.Laplacian(gray, cv2.CV_64F).var()
424
425 # Std dev (contrast/color variation)
426 std_dev = np.std(gray)
427
428 return laplacian_var, std_dev
429
430
431def is_complex_image(image_arr: np.ndarray, laplacian_threshold: float = 800, std_threshold: float = 50) -> bool:

Callers 1

is_complex_imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected