It has been demonstrated that atomic force microscopy imaging with CO-functionalized tips provides unprecedented resolution, yet it is subject to strong image distortions. Here we propose a method to correct for these distortions. The lateral force acting on the tip apex is calculated from three-dimensional maps of the frequency shift signal. Assuming a linear relationship between lateral distortion and force, atomic force microscopy images could be deskewed for different substrate systems. © 2014 American Physical Society.