Gimp-Forum.net

Full Version: Merging colors... How do it with Gimp?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

We obtain the secondary colors by superimposing the primary colors, such that:
Red + Yellow = Orange
Blue + Red = Purple
Yellow + Blue = Green

Is there any way to produce this with The Gimp?

[attachment=10132]

I laid each color in a layer and tried to get the secondary colors, I tried the layers modes and the composite mode, but without getting the expected results.

Thx!
Typically done in layers with layer masks for CMYK printing but as a single layer example

RGB (additive colours) use the brush in lighten-only mode

[attachment=10134]

CMY (subtractive colours) use the brush in darken-only mode

[attachment=10133]

Edit: Looking for old script that makes good examples - one of Saul Goodes - sg-decompose.scm 
It decomposes into layers either RGB or CMY - find it in the layers menu.
Attached, remember to unzip it.
As often happens I am not answering the question. A mix of RGB and CMY primary colours.

It might not be possible to get your example

This using different layer modes but for the Yellow - grain merge I had to reinforce with a sub-layer. Also Green is not bright green it is dark.

[attachment=10137]

To me it looks like a job for (possibly) inkscape.
Salut rich2005,

Your tip on how to proceed in the case of RGB (additive) and CMYK (subtractive) answered another question I had.  Smile

After reading your answer I still kept trying to find some way to get the orange, purple and green of the primary colors, only to fail again.  Rolleyes

Orange and purple were even obtained, basically the way you demonstrated in the previous post. But the green one... that didn't come up at all.

About the possibility of getting something with Inkscape, I also didn't get a satisfactory result (because I'm quite a noob in using Inkscape).
[attachment=10138]

I tested sg-decompose.scm, I'm sure I can do the same using Color Decompose by Pat David ➤ Image - Colors and Decompose <<  , and Decompose ➤ Image - Colors - Components <<

Thanks for the help and the plugin!
would changing the image mode to Indexed help? I tried and came up with nothing
(07-29-2023, 02:52 AM)sallyanne Wrote: [ -> ]would changing the image mode to Indexed help? I tried and came up with nothing

Hi Sally,

I think that in indexed mode the situation would repeat itself.

In the case of indexing the colors I would have to define a palette with both the initial colors (255,0,0 - 0,255,255 - 0,0,255) and the intended colors (Orange, purple and green), but then again we would be in the same situation demonstrated by previous rich2005 posts.

Thanks for suggesting a possibility! :-)
Hi Krikor, Smile

I assume that each circle is on its own layer (with alpha channel).

I suggest this:
  • Make all layers invisible (except the involved 3 ones)
  • Filters -> G'MIC-Qt -> Various -> Custom Code [Full]
  • Choose "All visible" in "Input layers"
  • Copy and paste this (in "Code"):
Code:
split_opacity
rgb2hsv[0,2,4]
repeat $! l[$<]
    split. c
done done
fill[0,4,8] if(i<60,i*2,if(i<120,i+60,if(i<240,i/2+120,i)))
a[8,9,10] c a[4,5,6] c a[0,1,2] c
hsv2rgb[0,2,4]
100%,100%,1,3
fill. i#0+i#2+i#4
rgb2hsv.
split. c
fill... if(i<120,i/2,if(i<180,i-60,if(i<240,i*2-240,i)))
a[-3,-2,-1] c
hsv2rgb.
100%,100%,1,1
fill. max(i#1,i#3,i#5)
a[-2,-1] c
a[4,5] c a[2,3] c a[0,1] c
mv. 0
  • Click 'OK'
Hope this helps!
Hi cli345,

Applying the code from your previous post surprisingly the thing works!

But, I am limited to applying this code only to this set of colors (red, yellow and blue). At least when trying with another set of colors I couldn't get the desired mixes.

I tried to extend the use of the code to generate tertiary colors, starting from mixing primary and secondary colors, but it didn't work.

[attachment=10144]

I relied in part on an article - Color Theory 101 ( https://blog.hubspot.com/marketing/color...%C3%AAs%0A )

It's a little frustrating that when I was a kid I could make these color mixes using crayons, but now with digital technology and the use of image editors this task seems so complicated.

Thanks for the code and willingness to help!  Smile
I had made it only for 3 layers and I forgot to restore the input layers.

Here is a fix:

Code:
split_opacity

rgb2hsv[0--1:2]
repeat $! l[$<]
    split. c
done done
fill[0--1:4] if(i<60,i*2,if(i<120,i+60,if(i<240,i/2+120,i)))

100%,100%,1,1
fill. x=0;y=0;for(n=0,n<l,x=x+i#(n+3)/255*cos(pi*i#n/180);y=y+sin(pi*i#n/180);n=n+4);(90-180*atan2(x,y)/pi)%360

fill[0--1:4] if(i<120,i/2,if(i<180,i-60,if(i<240,i*2-240,i)))

100%,100%,1,1
fill. m=0;for(n=1,n<l,m=max(m,i#n);n=n+4);m

100%,100%,1,1
fill. m=0;for(n=2,n<l,m=max(m,i#n);n=n+4);m

100%,100%,1,1
fill. m=0;for(n=3,n<l,m=max(m,i#n);n=n+4);m

repeat $!
    if $<%4==0
        second={$<+1}
        third={$<+2}
        local[$<,$second,$third]
            a c
        done
    fi
done

hsv2rgb[0--1:2]

repeat $!
    if $<%2==0
        second={$<+1}
        local[$<,$second]
            a c
        done
    fi
done
mv. 0
Wow!

I confess that I was a little frustrated with this (my) limitation in producing such color mixtures using The Gimp.

Now the result is just perfect!

[attachment=10149]

Looks like I have a lot of fun ahead :-)

cli345, I hope more people can take advantage of this code. Thank you very much!  Big Grin