1. A computer-implemented method for forming a panoramic image of a scene from a sequence of input frames captured by a camera having an optical center that translates relative to the scene, said scene having at least two points at different distances from a path of said optical center, said method comprising: obtaining an optical flow between corresponding points in temporally different input frames; using said optical flow to compute flow statistics for a plurality of different portions of each of at least some of said input frames; using said optical flow to compute respective stitching costs between some of said portions and respective neighboring portions thereof; identifying a sequence of selected portions and respective neighboring portions that minimizes a cost function that is a function of the flow statistics and the stitching costs, wherein at least one portion is identified by selecting a cut configured to minimize the cost function, wherein the cut is through a volume comprising the sequence of input frames, and wherein a border section of the at least one portion corresponds to a border section of a respective neighboring portion; and stitching the selected portions and respective neighboring portions so as to form a panoramic image of the scene.