Sobel filter doesn't respect ROI
I'm suspicious about how the Sobel filter treats non-continuous images.
Two identical images -- one made by changing the ROI of a larger image and the other by cloning -- produce different results when run through the filter:
#include <cassert>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
// Create a matrix that is all-zeros other than the last column
Mat orig(100, 100, CV_8U, cv::Scalar(0)), copy;
orig.col(orig.cols-1).setTo(255);
// Crop the last column out of the matrix in two ways:
// a) Using colRange, which only creates a new header
// b) Using copyTo, which creates a new header and data
orig = orig.colRange(0, orig.cols - 1);
orig.copyTo(copy);
// Assert that the matrices are the same
assert(countNonZero(orig != copy) == 0);
// Run a Sobel filter on both matrices
Sobel(orig, orig, CV_16S, 1, 0);
Sobel(copy, copy, CV_16S, 1, 0);
// Assert that the Sobel filter results are the same
assert(countNonZero(orig != copy) == 0);
}
This bit of sample code fails on the second assert statement.
(OpenCV 2.4.6.1 on Mac OS 10.6, 64-bit)
You should report your bug on the bug tracker. Thanks.