# Revision history [back]

### inconsistent behavior about ROI calculation

As we know:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) += com;


We will get a img like this:

This is out understandable behavior because we do a calculation in the same ROI. But why this code:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) = com;


cannot get a same result? I'm confusion about it. Or do I have missed something?

### inconsistent behavior about ROI calculation

As we know:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) += com;


We will get a img like this:

This is out understandable behavior because we do a calculation in the same ROI. But why this code:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) = com;


cannot get a same result? The img is empty image still:

I'm confusion about it. Or do I have missed something?

### inconsistent behavior about ROI calculation

As we know:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) += com;


We will get a img like this:

This is out understandable behavior because we do a calculation in the same ROI. But why this code:

Mat img(7, 8, CV_8UC1, Scalar(0));
Mat com = (Mat_<uchar>(4, 3) << 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255);
img(Rect(1, 2, 3, 4)) = com;


cannot get a same result? The img is empty image still:

I'm confusion about it. Or do I have missed something?