Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
mat0.at<double>(i, j);

that is the problem you have. check the type of mat0. it is probably 8-bit unsigned integer, probably 1-channel or 3-channel. Mat::at<> doesn't respect that, instead it just reinterprets the underlying bytes in memory and when you do ask it to give you a double from that, it's gibberish.

mat_ptr0[j*mat0.rows + i]

that is a bug as well. it hasn't bitten you because both your inputs are square. it should be mat0.cols because that's how many elements there are in one row.