Corrections in color detection algorithm