Constrained optimization for color pattern recognition with a nonzero