I wanted to use a guided filter on an image to compare bilateral and guided filters, but my guided filter code shows the error:
AttributeError: 'module' object has no attribute 'GuidedFilter'
How do I fix this error? My code is as follows:
import cv2
import numpy as np
img = cv2.imread("C:\\Users\\Saloni\\Pictures\\p1.jpg")
guided = cv2.GuidedFilter(img,13,70)
cv2.imshow("image",img)
cv2.imshow("guided filtering",guided)
cv2.waitKey()
The imguidedfilter function performs edge-preserving smoothing on an image, using the content of a second image, called a guidance image, to influence the filtering. The guidance image can be the image itself, a different version of the image, or a completely different image.
Image filtering is the process of modifying an image by changing its shades or color of the pixel. It is also used to increase brightness and contrast.
Blurring, Smoothing, Distortion, Warp Stabilizer, alpha extract, bilateral, color matrix, chrome hold are few video filters available in OpenCV.
A bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter for images. It replaces the intensity of each pixel with a weighted average of intensity values from nearby pixels.
GuidedFilter is not in core, but in the ximgproc contrib module.
So you'll have to make sure your OpenCV installation is built with contrib modules enabled in order to use GuidedFilter. If it's not, you might check this link.
If contrib modules are installed you can just do
from cv2.ximgproc import guidedFilter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With