我想裁剪一个 cv::Mat。请参阅如何在 OpenCV 中裁剪 CvMat?,我写了下面这段代码。
// I would like to crop around this central point.
x = 100;
y = 100;
int centerOff = 30, size = 61;
cv::Mat img2 = sourceImage(Rect((int)x-centerOff, (int)y-centerOff, size, size));
for (int i=0; i<size; i++) {
for (int j=0; j<size; j++) {
std::cout << (int)img2.at<uchar>(i, j) << " " << (int)sourceImage.at<uchar>(x-centerOff+i, y-centerOff+j) << "\n";
}
}
原来 img2 和 sourceImage 的输出是不同的。我想知道它的原因。