I tried to use ColorReplace
to change the colors obtained from MorphologicalComponents
. However some of the changes didn't follow the rules specified, Is there any reasons?
im2 = Binarize@Import["https://i.sstatic.net/ZDeYq.jpg"];
im3 = Colorize@ MorphologicalComponents@im2
colors = DominantColors[im3, 5]
Now trying to change the colors accordingly,
ColorReplace[im3, {
colors[[2]] -> Red,
colors[[3]] -> Blue,
colors[[4]] -> Green,
colors[[5]] -> Yellow
}]
One of the changes did not follow the rules specified: