Search code examples
c++opencvgaussianblur

strange gaussianBlur result offset of kernel multiplication unwantedly padded.


You can see the result in the image below. The original image is just a grey pixel, the result should be that but blurred.

Opencv is not using the immediate neighboring pixels for the Gaussian Blur, I'm guessing it's doing some sort of internal padding. Why it is doing so I have no idea, my initial guess would be that it assumes that the vector has more than one channel, which is not the case. Here is how i create the cv::Mats for calculation and how i call cv::gausianBlurr

std::vector<float> sobelCopy (sobel);
cv::Mat sobel_mat_copy(height, 
                       width, 
                       CV_32F, 
                       sobelCopy.data());

cv::Mat sobel_mat(height, 
                  width, 
                  CV_32F, 
                  sobel.data());

cv::GaussianBlur(sobel_mat_copy, sobel_mat, cv::Size(3,3), 0.0, 0.0, cv::BORDER_CONSTANT);

Image Resulting image


Solution

  • Fixed, it has all to with my how i ordered my vector, i had column major, cv::Mat assumes it is row major ordering.

    enter image description here