Doubt in Bounding Rectangle Algorithm

code:

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main() {
    for (int img_w = 3; img_w < 20; img_w++) {
        for (int img_h = 1; img_h < 15; img_h++) {
            Mat img(img_h, img_w, CV_8U, Scalar(0));
            img.row(img_h - 1)(Rect(0, 0, 3, 1)) = 255;

            Rect boundingRect = cv::boundingRect(img);

            if (boundingRect.width != 3) {
                cout << img_w << "x" << img_h << ": " << "w=" << boundingRect.width << endl;
            }
        }
    }

    return 0;
}

Output:

3x4: w=1
3x8: w=1
3x12: w=1
5x2: w=1
5x6: w=1
5x10: w=1
5x14: w=1
7x4: w=1
7x8: w=1
7x12: w=1
9x2: w=1
9x6: w=1
9x10: w=1
9x14: w=1
11x4: w=1
11x8: w=1
11x12: w=1
13x2: w=1
13x6: w=1
13x10: w=1
13x14: w=1
15x4: w=1
15x8: w=1
15x12: w=1
17x2: w=1
17x6: w=1
17x10: w=1
17x14: w=1
19x4: w=1
19x8: w=1
19x12: w=1

C:\Users\dhruv\source\repos\OpenCVtest\x64\Release\OpenCVtest.exe (process 18220) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.

‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Users\dhruv\source\repos\OpenCVtest\x64\Release\OpenCVtest.exe’. Symbols loaded.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\ntdll.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\kernel32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\KernelBase.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\ucrtbase.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\opencv\Builds\install\x64\vc17\bin\opencv_world480.dll’. Symbols loaded.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\gdi32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\win32u.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\gdi32full.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\msvcp_win.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\user32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\ole32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\rpcrt4.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\combase.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\ws2_32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\oleaut32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\comdlg32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\msvcrt.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\SHCore.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\shlwapi.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\shell32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\advapi32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\sechost.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\msvcp140.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\vcruntime140_1.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\vcruntime140.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.19041.1110_none_792d1c772443f647\comctl32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\mfplat.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\cfgmgr32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\mf.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\mfreadwrite.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\dxgi.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\d3d11.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\concrt140.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\mfcore.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\crypt32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\bcrypt.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\powrprof.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\ksuser.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\kernel.appcore.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\cryptbase.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\imm32.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\bcryptprimitives.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\RTWorkQ.dll’.
‘OpenCVtest.exe’ (Win32): Loaded ‘C:\Windows\System32\umpdc.dll’.
The thread 0x45c8 has exited with code 0 (0x0).
The thread 0x476c has exited with code 0 (0x0).
The thread 0x4f8 has exited with code 0 (0x0).
The program ‘[18384] OpenCVtest.exe’ has exited with code 0 (0x0).