Why ROI not changed

first, your program is throwing exeptions (did you even run it ?)

use cv::Rect(0, 0, 1, 1000); else its out of bounds

you are not changing the roi, but overwrite(reassign) the out_roi Mat header
it has all properies of diag_i now, and forgotten the prev. content

copying pixels to the roi works like this:

Mat src = ...// same size as rect & same type as outimg
src.copyTo(out(rect));

(which you cant do in your case, out_roi an diag_i having different sizes)

1 Like