Skip to content

Latest commit

Β 

History

History
181 lines (90 loc) Β· 3.44 KB

File metadata and controls

181 lines (90 loc) Β· 3.44 KB

🧠 Edge Detection & Thresholding App

🎯 Objective

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.


πŸ”§ Instructions

  1. 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


πŸ“ If Option 1 Selected: Apply Canny Edge Detection

User Interface:

  • 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)

Actions:

  • 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.


⚫ If Option 2 Selected: Apply Binary Thresholding

User Interface:

  • 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)

Actions:

  • 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.


🧠 If Option 3 Selected: Apply Adaptive Thresholding

User Interface:

  • 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

Actions:

  • 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.


πŸ’‘ If Option 4 Selected: Apply Bitwise Operations

User Interface:

  • Ask user to select two processed binary images (e.g., Canny + Thresholded).

  • Ask for bitwise operation type:

    • AND

    • OR

    • XOR

    • NOT (single image only)

Actions:

  • 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.


πŸ–ΌοΈ If Option 5 Selected: View Original Image

  • Simply display the uploaded image with no processing.

πŸ“„ Solution & 🌐 App