Reputation: 91
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()
Upvotes: 9
Views: 16886
Reputation: 1551
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
Upvotes: 12