Stereo rectify question

When use Matlab calibrate and rectify, img size change from 2592 x 1944 to 8805 x 2188.
But do not know how to realize this.
I think that the parameter of “stereoRectify” function, but how to do?
Can self-adaptive image size?

sorry, but this is the opencv site, we cannot help with matlab problems

Sorry, the previous description is not clear, this is not a problem with Matlab.

Image original size is 2592x1944.
After rectifying, its size should be 8805 x 2188, it is result of Matlab.

result correct of left image:

Below is OpenCV code:

image_size = (1944, 2592)
R1, R2, P1, P2, Q, roi_left, roi_right = cv2.stereoRectify(K1, D1, K2, D2, image_size, R, T, 
                flags=cv2.CALIB_ZERO_DISPARITY, alpha=-1)
leftMapX, leftMapY = cv2.initUndistortRectifyMap(K1, D1, R1, P1, image_size, cv2.CV_32FC1)
left_rectified = cv2.remap(left, leftMapX, leftMapY, cv2.INTER_LINEAR, cv2.BORDER_TRANSPARENT) 
rightMapX, rightMapY = cv2.initUndistortRectifyMap(K2, D2, R2, P2, image_size, cv2.CV_32FC1)
right_rectified = cv2.remap(right, rightMapX, rightMapY, cv2.INTER_LINEAR, cv2.BORDER_TRANSPARENT) 

The results are errors.

In cv2.stereoRectify, there is a parameter “newImageSize”.
If set newImageSize = (8805, 2188). the results are correct.
But roi_left, roi_right are erros.

Now, I would know:
How to calculate the newImageSize for self-adaptive image size?
How to calculate the effective ROI of the rectified image? For the next step, stereo matching.

result error of left image:

set newImageSize = (8805, 2188). the results are correct: