0

I'd like to replace, in GIMP, the white in this image with another color, like blue, but without affecting the dark grey that's on the left side of the gradient transition between the white and the grey. I'd like to preserve the shape and intensity of the gradient but just have it be a transition from dark grey to blue rather than white.

enter image description here

There are a lot of existing related questions, e.g.:

but I haven't found an answer that I've been able to use for this.

Some approaches I've tried:

Color to alpha -> color behind

We can do Color to alpha on white, and then paint blue in behind mode in order to paint just the transparency, but Color to alpha takes all the white out of the dark grey, too:

enter image description here

Color exchange

This comes up in some of my searches, but the Color exchange tool seems to strictly replace only the exact color specified in From Color.

enter image description here

Gradient map

With the dark grey and blue in my foreground/background color, Gradient map doesn't seem to work well either.

enter image description here

Loose illustration of desired effect

Just to convey the general idea in case it's not clear, I made this by hand tracing around the white and the gradient, doing color to alpha on white, increasing the contrast a bit, and then painting behind with blue. It's much too labor-intensive to do at scale of course, and still looks a tad strange, but this is the general idea.

enter image description here

1
  • Colour Exchange works better if you change the threshold see example - you can also experiment with the blending modes in this dialog
    – Billy Kerr
    Commented Apr 15, 2022 at 9:47

2 Answers 2

1

The technique I use is an improvement on the color-to-alpha one:

  1. Select the white with a low threshold (fuzzy select or color select, thois depends a bit on the image (include holes or not..., etc)
  2. Select > Grow the selection, so that it covers the transition pixels. Normally one pixel is enough, but if there are JPEG compression artifacts you can have to use two or three pixels.
  3. Apply Color-to-alpha, that now only acts on the background and the transition pixels.
0

If the white area really needs only a single color and the gradient area must not look less colorful, get them by adjusting the color curves:

enter image description here

I lifted your dark grey to 64 (=25% of full white brightness) to make the idea well visible.

The red curve is 64 at input range 0...64 and it drops to zero above 64. The steepness was adjusted so that the gradient doesn't contain visually any faint green nor red areas

Green curve has constant level =64.

Blue curve outputs 64 in input range 0...64 and then continues linearly to 255.

Here's another example with more reddish color:

enter image description here

And here's one with darker grey:

enter image description here

The horizontal zone in curves at 0...32 input range ensures the dark grey is uniform. If you want to keep the possible original dark grey area variations simply let the curves be in 45 degrees angle at the input range 0...32:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.