180-degree stitching algorithm