-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cv2.GaussianBlur produces darker results than input #9863
Copy link
Copy link
Closed
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete
Milestone
Description
System information (version)
- OpenCV => 3.3.0 master
- Operating System / Platform => Ubuntu 16.04 / x86_64
- Compiler => gcc 5.4
Detailed description
GaussianBlur produces darker results than the input image.
Original Image:
>>> cv2.imwrite('gaus.30.cv2.png', cv2.GaussianBlur(im, (151, 151), 30))$ gm convert gaus.0.png -blur 75x30 gaus.30.gm.png
Images should look the same, but this is obvious, that produced by OpenCV is much darker.
Proof that results produced by OpenCV is wrong
In theory, Gaussian blur shouldn't change color distribution or lightness. So, lets calculate lightness of the images:
# Using Pillow
from PIL import Image
def lightness(im):
hist = im.histogram()
return [
sum(i*v for i, v in enumerate(hist[:256])) / im.width / im.height,
sum(i*v for i, v in enumerate(hist[256:512])) / im.width / im.height,
sum(i*v for i, v in enumerate(hist[512:])) / im.width / im.height
]
# [59.76, 69.08, 40.2]
print(lighnes(Image.open('gaus.0.png')))
# [59.73, 69.18, 39.94]
print(lighnes(Image.open('gaus.30.gm.png')))
# [53.86, 62.26, 36.22]
print(lighnes(Image.open('gaus.30.cv2.png')))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete


