Bug in OpenCV2.3 cv::split() function. Identical values in all 3 channels

后端 未结 1 1670
北海茫月
北海茫月 2021-01-21 03:02

After spending a couple of days trying figure out why opencv DFT would give 100% similar results for all three channels I ended up finding out that there might be a bug in the s

1条回答
  •  执笔经年
    2021-01-21 03:37

    It is not a bug in OpenCV but there is a problem with your code.

    The following line does not create a vector of 3 different Mats:

    std::vector rgbChannels(3,cv::Mat(inputImage.size(),CV_64FC1));
    

    Instead, this line produces a vector of 3 Mat headers sharing the same memory. It works this way because Mat copy constructor does not make a deep copy - it just increments an internal reference counter.

    Just change your code to the following to solve your problem:

    std::vector rgbChannels(3);
    cv::split(inputImage, rgbChannels);
    

    0 讨论(0)
提交回复
热议问题