The bold position that the final result shows, the red position where it went for the R, G and B. It takes a position (in red) and replaces another (in bold) for that. One can get confused what is bold or red, but the end result is the same.

What I mean is that you think evil in the algorithm. You should replace the two positions and run the algorithm by half the length of the image.

You need a temporary variable that stores the value of the pixel you are going to modify, then as that has the pixel color pixel corresponding to the opposite side, and while you lack: replace the pixel on the side opposite the temporary variable that has pixel value of the original.