Changed the condition for image derivatives.