I would like to replace the colors in this drawing (called
img) with colors of my choice. (For simplicity, we can assume my desired colors are
i = 0, .1, ..., 1.)
I have used
DominantColors[img] to extract the principal colors and then used
where the options are a list of associations, where White -> White and each of the remaining principal colors gets mapped to the Rainbow colors. Alas, because (I think) the distributions of colors are far from uniform, and because the edges of each line "blur" colors, the process never works. Each line in the drawing that should be a single color gets split.
EdgeDetection, in various forms, but never quite get what I seek.
I think I'm missing some image processing function that will sharpen each line and ensure each pixel is quantized to the proper color, but just can't find that function.