Build an interactive CLI or Streamlit tool that allows users to upload an image, apply edge detection and thresholding techniques, and view/download the processed image using OpenCV.
- Ask user:
"What would you like to do with the image?"
Choose one of the following options:
-
1. Apply Canny Edge Detection -
2. Apply Binary Thresholding -
3. Apply Adaptive Thresholding -
4. Apply Bitwise Operations -
5. View Original Image
-
Ask user to upload an image or provide file path (CLI).
-
Convert image to grayscale.
-
Ask for:
-
Lower Threshold(e.g., 50) -
Upper Threshold(e.g., 150)
-
-
Apply Canny using:
cv2.Canny(gray_img, lower, upper)
-
Display the edge-detected image.
-
Offer Download option.
π Note: Canny detects edges based on image gradients and hysteresis thresholding.
-
Ask user to upload an image or provide file path (CLI).
-
Convert image to grayscale.
-
Ask for:
-
Threshold value(e.g., 127) -
Max value(e.g., 255)
-
-
Apply Binary Thresholding using:
cv2.threshold(gray_img, thresh_val, max_val, cv2.THRESH_BINARY)
-
Display the binary image.
-
Offer Download option.
π Note: Pixels above the threshold become white, others black β useful for high-contrast segmentation.
-
Ask user to upload an image or provide file path (CLI).
-
Convert image to grayscale.
-
Ask for:
-
Block Size(odd number, e.g., 11, 15, 21) -
C value(e.g., 2) -
Methodβ choose between:-
cv2.ADAPTIVE_THRESH_MEAN_C -
cv2.ADAPTIVE_THRESH_GAUSSIAN_C
-
-
-
Apply Adaptive Thresholding using:
cv2.adaptiveThreshold(gray_img, 255, method, cv2.THRESH_BINARY, block_size, C)
-
Display the adaptively thresholded image.
-
Offer Download option.
π Note: Adaptive methods apply different thresholds in local regions of the image β useful under uneven lighting.
-
Ask user to select two processed binary images (e.g., Canny + Thresholded).
-
Ask for bitwise operation type:
-
AND -
OR -
XOR -
NOT(single image only)
-
-
Apply bitwise operation using:
cv2.bitwise_and(img1, img2) cv2.bitwise_or(img1, img2) cv2.bitwise_xor(img1, img2) cv2.bitwise_not(img1)
-
Display the result.
-
Offer Download option.
π Note: Bitwise operations are often used to combine masks or highlight specific regions.
- Simply display the uploaded image with no processing.