Automatic image segmentation of grain based on illumination categorization