Fixed bug in routines for obtaining background pixels