| |
|
| |
|
| | import cv2
|
| | import numpy as np
|
| | import os
|
| |
|
| | def create_sample_images():
|
| | """Create sample blurred and sharp images for testing"""
|
| |
|
| |
|
| | os.makedirs('data/sample_images', exist_ok=True)
|
| |
|
| |
|
| | height, width = 480, 640
|
| |
|
| |
|
| | sharp_image = np.zeros((height, width, 3), dtype=np.uint8)
|
| |
|
| |
|
| | cv2.rectangle(sharp_image, (50, 50), (200, 150), (255, 0, 0), -1)
|
| | cv2.circle(sharp_image, (400, 200), 80, (0, 255, 0), -1)
|
| | cv2.line(sharp_image, (100, 300), (500, 350), (0, 0, 255), 5)
|
| |
|
| |
|
| | cv2.putText(sharp_image, 'SHARP IMAGE TEST', (150, 400),
|
| | cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
|
| |
|
| |
|
| | cv2.imwrite('data/sample_images/sharp_test.png', sharp_image)
|
| |
|
| |
|
| | motion_kernel = np.zeros((15, 15))
|
| | motion_kernel[7, :] = 1/15
|
| | motion_blurred = cv2.filter2D(sharp_image, -1, motion_kernel)
|
| | cv2.imwrite('data/sample_images/motion_blurred.png', motion_blurred)
|
| |
|
| |
|
| | gaussian_blurred = cv2.GaussianBlur(sharp_image, (15, 15), 5)
|
| | cv2.imwrite('data/sample_images/defocus_blurred.png', gaussian_blurred)
|
| |
|
| |
|
| | noise = np.random.normal(0, 25, sharp_image.shape).astype(np.uint8)
|
| | noisy_blurred = cv2.add(gaussian_blurred, noise)
|
| | cv2.imwrite('data/sample_images/noisy_blurred.png', noisy_blurred)
|
| |
|
| | print("Sample images created successfully!")
|
| | print("Files created:")
|
| | print("- data/sample_images/sharp_test.png")
|
| | print("- data/sample_images/motion_blurred.png")
|
| | print("- data/sample_images/defocus_blurred.png")
|
| | print("- data/sample_images/noisy_blurred.png")
|
| |
|
| | if __name__ == "__main__":
|
| | create_sample_images() |