CNN-based Image Filtering and
Visualization
Understanding Edge Detection with
Sobel Filters
Overview
• This presentation demonstrates how a CNN
with a Sobel filter processes images:
• - Applies Sobel filter to original and blurred
images
• - Visualizes edge detection behavior
• - Uses a single Conv2D layer without activation
Step 1: Install Dependencies
• !pip install tensorflow opencv-python
matplotlib --quiet
Step 2: Download Image
• Download a sample image from Wikimedia:
• - URL: Golden retriever image
• - Saved as 'dog.jpg'
Step 3: Load & Preprocess Image
• - Convert to grayscale
• - Resize to 128x128
• - Normalize pixel values
• - Reshape to (1, 128, 128, 1)
Step 4: Build CNN Model
• - Single Conv2D layer
• - 1 filter, 3x3 kernel
• - No activation function
• - No bias
Step 5: Set Sobel Filter
• Manually set the Conv2D weights to a Sobel X
filter:
• [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
• Detects vertical edges
Step 6: Apply Filter to Original
• - Use model.predict on the original image
• - Get 2D filtered output
• - Shows detected edges
Step 7: Blur and Filter Again
• - Apply Gaussian blur to original
• - Filter blurred image using same CNN
• - Shows reduced edge intensity
Step 8: Visualization
• Show 4 subplots:
• - Original
• - CNN Filtered
• - Blurred
• - CNN Filtered on Blurred
Conclusion
• This example demonstrates:
• - How CNNs use filters for feature detection
• - Sobel filter behavior
• - Effect of blurring on edge detection
What is a CNN Model?
• A Convolutional Neural Network (CNN) is a
deep learning model used primarily for image
processing tasks.
• Key Components:
• 1. **Convolutional Layers** – Extract local
features from the input image using filters.
• 2. **Activation Function (ReLU)** – Adds non-
linearity to the network.

CNN_Image_Filtering_Presentation_Updated.pptx

  • 1.
    CNN-based Image Filteringand Visualization Understanding Edge Detection with Sobel Filters
  • 2.
    Overview • This presentationdemonstrates how a CNN with a Sobel filter processes images: • - Applies Sobel filter to original and blurred images • - Visualizes edge detection behavior • - Uses a single Conv2D layer without activation
  • 3.
    Step 1: InstallDependencies • !pip install tensorflow opencv-python matplotlib --quiet
  • 4.
    Step 2: DownloadImage • Download a sample image from Wikimedia: • - URL: Golden retriever image • - Saved as 'dog.jpg'
  • 5.
    Step 3: Load& Preprocess Image • - Convert to grayscale • - Resize to 128x128 • - Normalize pixel values • - Reshape to (1, 128, 128, 1)
  • 6.
    Step 4: BuildCNN Model • - Single Conv2D layer • - 1 filter, 3x3 kernel • - No activation function • - No bias
  • 7.
    Step 5: SetSobel Filter • Manually set the Conv2D weights to a Sobel X filter: • [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]] • Detects vertical edges
  • 8.
    Step 6: ApplyFilter to Original • - Use model.predict on the original image • - Get 2D filtered output • - Shows detected edges
  • 9.
    Step 7: Blurand Filter Again • - Apply Gaussian blur to original • - Filter blurred image using same CNN • - Shows reduced edge intensity
  • 10.
    Step 8: Visualization •Show 4 subplots: • - Original • - CNN Filtered • - Blurred • - CNN Filtered on Blurred
  • 11.
    Conclusion • This exampledemonstrates: • - How CNNs use filters for feature detection • - Sobel filter behavior • - Effect of blurring on edge detection
  • 12.
    What is aCNN Model? • A Convolutional Neural Network (CNN) is a deep learning model used primarily for image processing tasks. • Key Components: • 1. **Convolutional Layers** – Extract local features from the input image using filters. • 2. **Activation Function (ReLU)** – Adds non- linearity to the network.