In order to detect salient lines in spherical images, we consider the problem of minimizing the functional ∫0lC(γ(s))ξ2+kg2(s)ds for a curve γ on a sphere with fixed boundary points and directions. The total length l is free, s denotes the spherical arclength, and kg denotes the geodesic curvature of γ. Here the smooth external cost C≥ δ> 0 is obtained from spherical data. We lift this problem to the sub-Riemannian (SR) problem in Lie group SO(3) and show that the spherical projection of certain SR geodesics provides a solution to our curve optimization problem. In fact, this holds only for the geodesics whose spherical projection does not exhibit a cusp. The problem is a spherical extension of a well-known contour perception model, where we extend the model by Boscain and Rossi to the general case ξ> 0 , C≠ 1. For C= 1 , we derive SR geodesics and evaluate the first cusp time. We show that these curves have a simpler expression when they are parameterized by spherical arclength rather than by sub-Riemannian arclength. For case C≠ 1 (data-driven SR geodesics), we solve via a SR Fast Marching method. Finally, we show an experiment of vessel tracking in a spherical image of the retina and study the effect of including the spherical geometry in analysis of vessels curvature. © 2017, The Author(s).