diff --git a/a.jpg b/a.jpg new file mode 100644 index 0000000..b8267af Binary files /dev/null and b/a.jpg differ diff --git a/b.jpg b/b.jpg new file mode 100644 index 0000000..99dce7c Binary files /dev/null and b/b.jpg differ diff --git a/dedup.py b/dedup.py index 7568b84..dc8d4be 100644 --- a/dedup.py +++ b/dedup.py @@ -346,6 +346,12 @@ def find_duplicate_with_rotation(img1, img2): # Return similarity score (lower is more similar) return len(matches) + +def get_image_dimensions_cv(img): + if img is not None: + height, width = img.shape[:2] + return width, height + return None """ xxhash is about 5–10x faster than SHA256, non-cryptographic. @@ -383,6 +389,16 @@ if __name__ == "__main__": # Load large images large_img1 = cv2.imread(file1) # e.g., 4000x3000 pixels large_img2 = cv2.imread(file2) # e.g., 4000x3000 pixels + + w, h = get_image_dimensions_cv(large_img1) + w2, h2 = get_image_dimensions_cv(large_img2) + if w != w2 and w != h2: + print("Diffent Resolutions") + exit(0) + + if h != h2 and h != w2: + print("Diffent Resolutions") + exit(0) # Align with downscaling (initially process at 1/4 size) aligned, matrix, angle = align_with_downscaling( @@ -397,12 +413,22 @@ if __name__ == "__main__": # Print debug info print(f"Detected rotation: {angle}°") print(f"Final transformation matrix:\n{matrix}") - - score = find_duplicate_with_rotation(large_img1, aligned) - print(f"Score: {score}") # Calculate scores matrix_score = matrix_similarity_score(matrix) + + if len(sys.argv) > 3: + is_score = sys.argv[3] + else: + is_score = "" + + if matrix_score == 1.0 and is_score != "scores": + print("✅ Perfect Matrix score, should be identical") + exit(1) + if is_score == "scores": + score = find_duplicate_with_rotation(large_img1, aligned) + print(f"Score: {score}") + decomposed_score = decomposed_similarity_score(matrix, large_img1.shape[1]) combined_score = comprehensive_similarity(large_img1, aligned, matrix)