An image data set acquired by an optical coherence tomography (OCT) system is corrected for effects due to motion of the sample. A first set of A-scans is acquired within a time short enough to avoid any significant motion of the sample. A second more extensive set of A-scans is acquired over an overlapping region on the sample. Significant sample motion may occur during acquisition of the second set. A-scans from the first set are matched with A-scans from the second set, based on similarity between the longitudinal optical scattering profiles they contain. Such matched pairs of A-scans are likely to correspond to the same region in the sample. Comparison of the OCT scanner coordinates that produced each A-scan in a matching pair, in conjunction with any shift in the longitudinal scattering profiles between the pair of A-scans, reveals the displacement of the sample between acquisition of the first and second A-scans in the pair. Estimates of the sample displacement are used to correct the transverse and longitudinal coordinates of the A-scans in the second set, to form a motion-corrected OCT data set.