import cv2
import numpy as np
import [Link] as plt
# Load the image
image_path = r'C:\Users\dell\Desktop\[Link]' # Change this path
image = [Link](image_path)
# Check if the image loaded successfully
if image is None:
print("Error: Could not load image.")
else:
# Split the image into its Red, Green, and Blue channels
b, g, r = [Link](image)
# Apply median filtering to each channel separately
r_filtered = [Link](r, 5)
g_filtered = [Link](g, 5)
b_filtered = [Link](b, 5)
# Merge the filtered channels back together
filtered_image = [Link]((b_filtered, g_filtered, r_filtered))
# Display the original and filtered images
[Link](figsize=(10, 5))
[Link](1, 2, 1)
[Link]('Original Image')
[Link]([Link](image, cv2.COLOR_BGR2RGB))
[Link]('off')
[Link](1, 2, 2)
[Link]('Filtered Image')
[Link]([Link](filtered_image, cv2.COLOR_BGR2RGB))
[Link]('off')
[Link]()
# Optionally save the filtered image
[Link](r'C:\Users\dell\Desktop\[Link]', filtered_image) # Change this path