Assignment 1 Code
Assignment 1 Code
import numpy as np
from google.colab import files
from google.colab.patches import cv2_imshow
return choice
if choice == 1:
negate_image(image)
elif choice == 2:
threshold_value = int(input("Enter threshold value (0-255):
"))
threshold_image(image, threshold_value)
elif choice == 3:
extract_and_display_bit_planes(image)
elif choice == 4:
lower_bound = int(input("Enter lower bound for slicing
(0-255): "))
upper_bound = int(input("Enter upper bound for slicing
(0-255): "))
gray_level_slicing(image, lower_bound, upper_bound)
elif choice == 5:
print("Exiting program.")
break
else:
print("Invalid choice. Please enter a number between 1 and
5.")
Output :
Please upload the image file.
Upload widget is only available when the cell has been executed in the current browser session.
Please rerun this cell to enable.
Saving DOG.JPG to DOG.JPG
Original Image:
Bit Plane 2:
Bit Plane 3:
Bit Plane 4:
Bit Plane 5:
Bit Plane 6:
Bit Plane 7:
Image Processing Menu:
1. Negate Image
2. Threshold Image
3. Extract and Display Bit Planes
4. Gray Level Slicing
5. Exit
Enter your choice (1-5): 4
Enter lower bound for slicing (0-255): 154
Enter upper bound for slicing (0-255): 187
Gray Level Slicing for range (154, 187):
Sliced Image Matrix:
[[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]]
Gray level sliced image saved as 'gray_level_sliced_154_187.jpg'.