I have the following:
string input = "test.jpg";
cv::Mat tmp = cv::imread(input, CV_LOAD_IMAGE_COLOR);
cv::Mat img1;
cv::cvtColor(tmp, img1, CV_BGR2GRAY);
cv::Mat img2 = cv::imread(input, cv::IMREAD_GRAYSCALE);
isMatEqual(img1, img2);
where isMatEqual()
:
bool isMatEqual(const cv::Mat & a, const cv::Mat & b)
{
if ( (a.rows != b.rows) || (a.cols != b.cols) )
return false;
cv::Scalar s = sum( a - b );
return (s[0]==0) && (s[1]==0) && (s[2]==0);
}
However I am not getting an equality when comparing the 2 images. If I am forced to read the image in first and then do a cvtColor()
transform to grayscale, what would be a correct parameter to set such that img1 == img2
?