Image Processing Algorithm for Apple Defect Detection