Expert and intelligent systems based on computer-vision algorithms are becoming a common part of our daily lives, as they help us solve problems in areas such as medicine, agriculture, transportation, and ecology. In this paper, we focus on the application of computer vision in marine ecology. Here, we propose a new algorithm for mosaicing images of coral reefs captured by scuba divers using hand-held cameras during reef surveys. Such images often capture partial views of the surveyed area that are then collated into mosaics of the reef assemblages. Accurate mosaics will help coral-reef researchers rapidly assess not only the status of coral reefs, but also determine rates of recovery or rates of decline using longitudinal data. Most standard mosaicing algorithms distort the images, however, and moving objects and parallax errors, which usually happen in underwater images, hinder mosaic construction. To overcome these issues, our new algorithm uses a two-step approach that first detects and then removes loops and low-quality regions from an estimated camera trajectory. The algorithm then stitches the remaining images by warping parallax-affected image regions with a geometric transformation different from the one used for parallax-unaffected regions. We tested our method on images captured during a large spatial survey of coral reef sites throughout the Caribbean region. Our method obtained better-quality mosaics than other state-of-the-art algorithms.