Lab 9 (1)
Lab 9 (1)
Ans 1
Step 1: Read and Convert Image to Grayscale
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('coins.jpg') # Replace with actual path
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(gray, cmap='gray')
plt.title("Grayscale Image")
plt.axis("off")
plt.show()
Step 3: Thresholding
_, thresh = cv2.threshold(blurred, 130, 255, cv2.THRESH_BINARY_INV)
plt.imshow(thresh, cmap='gray')
plt.title("Thresholded Image")
plt.axis("off")
plt.show()
Processed Images
Here are the processed images showing each step of the coin detection pipeline: