output_path.parent.mkdir(parents=True, exist_ok=True) if not cv.imwrite(str(output_path), edges): raise SystemExit(f"could not write image: {output_path}") edge_pixels = cv.countNonZero(edges) edge_percent = edge_pixels / edges.size * 100 print(f"input: {input_path}") print(f"image size: {gray.shape[1]}x{gray.shape[0]}") print("thresholds: 80/160") print(f"edge pixels: {edge_pixels} ({edge_percent:.2f}%)") print(f"output: {output_path}")