Changing webcam-pixels to "nearest" color from color palette array

Thanks for the tips! I have only done blob detection, erosion + dilation with a black/white image after thresholding. Any examples of how to do it with specific colors?