This is a follow up on the new changes made to Color Editor in case you've not seen my previous videos on how this works you should start with this on how to color black and white images followed by this on swapping colors in a colored image. One of the few issues it had was how hard it was to select all the shades of a color like blue in an image and after some research I found HSV has a better color code correlation than rgb so it made for an easier method to select all 'hues' of color.
The image above shows how Hue covers all the colors while saturation covers how light it is while value covers how dark it is.
HSV did get me close to getting most of the colors quickly but you'd have to select around 5 sections of the images just to get enough sampling area to get all the color.
I later on found out it's possible from StackOverflow to improve the selection by blurring the image. This makes the image colors less abrupt and therefore the hue value shifts less.
Here's the image I used in my example
After blurring it looks like this
The blur isn't a lot and that's using the default settings but with that selecting just a small portion of the image gets me about 90% of all the color I wanted to target which is perfect.
This is how the code looks for the hsv selection
It's pretty straight forward: it gets the image and positions, blurs the image, gets the hue value for the positions (selection area) checks the image for positions with the listed hues and then using this builds a new list of positions which then is used to sample the colors more generally.
This is how the result looks finally after switching color, keep in mind that I also did select the area to swap color.