Rotate image 90 degree clockwise
This code doesn't rotate the image 90 degrees clockwise.

We can see this by making each entry in the matrix distinct (the important part is moving value++ inside the inner loop)

for (auto&amp; i : image)
{
    for (auto&amp; j : i)
    {
        cout &lt;&lt; setfill(' ') &lt;&lt; setw(3) &lt;&lt; (j = value) &lt;&lt; ' ';
        value++;
    }

    cout &lt;&lt; '\n';
}


Then the output is

$ ./a.exe
******* original image ******
  0   1   2   3   4   5   6
  7   8   9  10  11  12  13
 14  15  16  17  18  19  20
 21  22  23  24  25  26  27
 28  29  30  31  32  33  34
 35  36  37  38  39  40  41
 42  43  44  45  46  47  48

******* rotated image ******
 48  41  34  27  20  13   6
 47  40  33  26  19  12   5
 46  39  32  25  18  11   4
 45  38  31  24  17  10   3
 44  37  30  23  16   9   2
 43  36  29  22  15   8   1
 42  35  28  21  14   7   0