Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imread, imwrite does not give similar image

I have the following code:

string src = "a.jpg";
string dest = "a_out.jpg";

cv::Mat im = cv::imread(src, CV_LOAD_IMAGE_COLOR);
cv::imwrite(dest, im);
cv::Mat im2 = cv::imread(dest, CV_LOAD_IMAGE_COLOR);
isMatEqual(im,im2);

where:

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 get a return that is false. Is there something wrong my reading/writing of the images?