Modularized distances and pixel values so that code is more maintainable and customizable