Optimizing image processing methods with applications