Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".

Hi, i'm using IM version 6.8.9-9 on Ubuntu Linux and am attempting to recolorize this image of a fabric tuft:

By recolorize i mean that i want to change the blue and green areas to a different color but maintain the difference that currently exists (e.g. there are lots of shades of blue, so i want to replace those with the relative shade of my red color which is "rgb(239,70,36)" ).

I do have the option to split the image into separate blue and green versions and process them separately.

I've looked through the IM documentation and this forum extensively and tried everything i can find but just can't seem to get it working right.

I added an example above with your image. I do not know what you consider the blue input color, so I just measure the blue shade at some pixel in your image. Change the blue color as desired or the red color.

If we want to change green into red, and blue into purple, we can combine the previous two results with a mask. Notice that you have anti-aliasing where green and blue merge. By inspecting the hue channel, I find that green is about 33% and blue is about 68%. The middle of this is 50.5. 10% on either side is 40.5% to 60.5%. We will create a ramp in this range.

Just one more aspect if you don't mind, is there a way to 'lighten' the replaced color so it appears closer to the replaced color (rgb(239,70,36))?

Forgive me if this explanation is lacking, but essentially what I am doing is recoloring this image, sizing it down to approx. 25px-60px wide, then repeating it dozens of times to give the impression of a rug. When viewed as a complete image the 'texture' of the individual loops is apparent which makes it look like a rug, but currently the perceived color is darker than the rgb(239,70,36).

I appreciate this is tricky as the blues in the source image are dark, so if I wanted to make this universal (meaning the blue could be replaced with any color, and then when sized down or zoomed out the aggregate result appeared close to the new color) is there a better choice of color for the blue (e.g. changing it to shades or gray), or is there a adjustment that could be made to 'lighten up' the color change to get closer?

Thank you both again for your time and help - I ended up changing the image i was using to have more neutral colors, and then added additional code to look at the relative values of the RGB color we were replacing to. Via this i then used a variation of: