Assignment 01
Assignment 01
4.10.0
import cv2
# Read an image in grayscale
image = cv2.imread(r'C:\Users\reema\OneDrive\Desktop\DIP\Fig0338(a)
(blurry_moon).tif', 0) # 0 for grayscale
# Read an image in color
image_color = cv2.imread(r'C:\Users\reema\OneDrive\Desktop\DIP\pexels-
mccutcheon-1191710.jpg', 1) # 1 for color (RGB)
plt.show()
# Resize using specific dimensions (200x200 pixels)
resized_image = cv2.resize(image, (200, 200))
resized_image_color = cv2.resize(image_color, (200, 200))
plt.tight_layout()
plt.show()
# Original Image
plt.subplot(1, 2, 1)
plt.imshow(image, cmap='gray')
plt.title('Original Image')
plt.axis('off')
# Rotated Image
plt.subplot(1, 2, 2)
plt.imshow(rotated_image, cmap='gray')
plt.title('Rotated Image (90° Clockwise)')
plt.axis('off')
plt.tight_layout()
plt.show()
# Load two grayscale images
image1 = cv2.imread(r'C:\Users\reema\OneDrive\Desktop\DIP\image1.bmp',
cv2.IMREAD_GRAYSCALE) # Replace with your image path
image2 = cv2.imread(r'C:\Users\reema\OneDrive\Desktop\DIP\image2.bmp',
cv2.IMREAD_GRAYSCALE) # Replace with your image path