CHANGE: Refactored. Can now apply analysis to an arbitrary image.