-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
OpenCV 4.5.2 GaussianBlur not working properly with UInt16 image type #20121
Copy link
Copy link
Closed
Milestone
Description
System information (version)
- OpenCV => 4.5.2
- Operating System / Platform => Linux 64 Bit and OS X 64 Bit
- Compiler => clang
Detailed description
When performing cv::GaussianBlur() on an image of type CV_16UC1, it seems that all values above uint16::max/2 are clipped to uint16::max/2. When performing the gaussian blur using cv::getGaussianKernel() combined with cv::filter2D it works fine. The same problem was definitely not there when using OpenCV version 4.2.0. Running the cv::GaussianBlur() in-place or not doesn't make a difference. Probably internally at some point the pixel values are casted to a signed 16 bit integer and therefore are clipped to 32768.
Steps to reproduce
cv::Mat img(100, 100, CV_16UC1);
img = cv::Scalar(std::numeric_limits<uint16_t>::max());
cv::imwrite(basePath + "gaussianDebugOriginal.png", img);
cv::GaussianBlur(img, img, cv::Size(9, 9), 0.0);
cv::imwrite(basePath + "gaussianDebugBlurred.png", img);Reactions are currently unavailable

