I have some images in which I expect to have some red, green, blue, or yellow areas. Like this image:
myImage =
Now, I'd like to get 4 binary images, representing each of the 4 colors. What I'd like to have is a process that decides, pixel by pixel, which of the 4 colors is closest (or black). I know we can do something like this to split the RGB channels:
Binarize[#, 0.25] & /@ ColorSeparate[myImage]
My primary question is, how could I add the yellow color (or any other color) to the color separation? A related question, does ColorSeparate
ensures that no two binary images share a white (foreground) pixel? By eye I don't see much overlap, but I imagine if two colors are close together they might be assigned to two binary images(?), say, orange & yellow. If so, how to ensure that each foreground pixel is only present in exactly one of the binary images? I was thinking on using something similar to what is in this question, but it seems that a distance from a color would not work with similar colors (some pixels would be assigned to two binary images).
Thanks!
ColorDistance[]
to figure out, for each pixel of the query image, which of the 4 colors (or black) has the smallest distance. Then, assign this pixel to the foreground (white) of a binary image representing that color binarization, getting 4 binary images at the end. $\endgroup$Color
objects and functions seems to be somewhat slow in my experience. I was going to do it using the raw channel data, but just wanted to know if you had a color distance in mind. I believe the default is Euclidean distance using LAB color data. $\endgroup$