Hue Overlay Masks - my first filter

Hi there,

I made my first filter in G’mic and even though I fear something like this is already available inside the plethora G’mic filters, I thought I’d share it. It basically creates three layers based on the hues R, G and B. I use these either in overlay or soft light mode to boost or dampen certain hues, or I use them as masks to select certain hues and work them.
Some examples:
Basic image

Inverted blue layer in soft light mode, darken blues, lighten yellows:

Inverted blue layer plus blue mask, to darken the blues without brightening the yellows:

Copy of base image with a red mask to select reddish hues, then added contrast and saturation:

Technically the filter works like this. Think of a color wheel. To create the red layer, prject the blue and green “vectors” onto the red “axis” and subtract both from the red value. In you created layer all colors from the half circle where the red lays are brighter than neutral grey, all other are darker. Same is done for the other colors.

Maybe it is of interest to somebody.

Here’s the code:
#@gimp Hue Overlay Masks : hue_overlay_masks, hue_overlay_masks_preview(0)
#@gimp : note = note{"\n"}
#@gimp : note = note{“This plugin creates RGB hue masks. They are be exported in overlay mode into Gimp. Try each one to see how it changes your picture. Alternatively you can use them as masks to select regions based on hue.”}
#@gimp : sep = separator()
#@gimp : Stretch constrast = bool(0)
hue_overlay_masks :

	100%,100%,1,1,"R#0/2-(G#0+B#0)/4+128"
	100%,100%,1,1,"G#0/2-(R#0+B#0)/4+128"
	100%,100%,1,1,"B#0/2-(R#0+G#0)/4+128"
	-name[-3] "name(Red), mode(overlay)"
	-name[-2] "name(Green),mode(overlay)"
	-name[-1] "name(Blue),mode(overlay)"
	-if {$1==1}
		-if '{iM[1]-128 > 128-im[1]}'
			-fill[1] '(i-128)/abs(iM-128)*128+128'
		-else
			-fill[1] '(i-128)/abs(im-128)*128+128'
		-endif
		-if '{iM[2]-128 > 128-im[2]}'
			-fill[2] '(i-128)/abs(iM-128)*128+128'
		-else
			-fill[2] '(i-128)/abs(im-128)*128+128'
		-endif
		-if '{iM[3]-128 > 128-im[3]}'
			-fill[3] '(i-128)/abs(iM-128)*128+128'
		-else
			-fill[3] '(i-128)/abs(im-128)*128+128'
		-endif
	-endif
	-move[1] 0
	-move[2] 1
	-move[3] 2
	fx_split_colors_preview : -gui_split_preview "-fx_split_colors $*",$-1
4 Likes

Cool. Is that something that you do so often that you decided to write your own filter? That is the case for myself. G’MIC is versatile that way.

I’ve added your filters in Testing / McCap /.

I had to make some modifications to make it work, as the comments #@gimp have been replaced by #@gui since version 2.0 of G’MIC (at least :slight_smile: ). Your filter should be visible from anyone in a few minutes, after a filter refresh.
Here is the code I’ve added to the gmic-community repository : gmic-community/mccap.gmic at master · dtschump/gmic-community · GitHub

Let me know if that is working as expected !

1 Like

Nifty filter! Just a question about what exactly you’re doing when you say “inverted blue layer plus blue mask”, would that consist of the following steps?

  1. Run your filter and inactivate the red and green layers.
  2. Duplicate the newly created blue layer.
  3. Colors->Invert one of the blue layers
    So, the active layers would be the original background, the inverted blue and the other blue layer.

Is that it? Or, is it this?

  1. Run your filter and inactivate the red and green layers.
  2. Drag the blue filter to the channels.
  3. Go back to layers and Colors->Invert the blue layer.
  4. Add a layer mask to the inverted blue layer from the created blue channel.

Sorry if that seems like splitting hairs or making it overly complicated but it appears to make a difference and I was wondering which you were doing.

Hope all that makes sense and really appreciate again the filter!

Cheers,
Jules

@afre, Kind of. I love using masks and overlay layers. I didn’t like that when I decomposed a picture the blue channel would also select all the white areas, because the blue value was large there. So I tried to think how to make some hue based mask and came up with this. Then I decided that G’mic would be the best and fastest way to learn to make some filters.

@David_Tschumperle, thank you for including the filter and thank you for also correcting the preview. And also thank you for creating this cool language!!! :star_struck:
I also have a question. I thought I would use this day to update my old G’mic to the new version. After installing it and starting Gimp I get this error telling me that it can’t find libidn-11.dll on my computer. And actually I can’t find it either. Any idea what I could/should do?

@jules it is not spitting hair. I did the second version. :slight_smile:

I’m not running Windows very often, so I’m probably not the best person to ask :slight_smile:
The only thing I can do is suggesting reading this topic : Using the Windows installer for version 2.0.3+ of G'MIC
and if there is .dll missing, try getting it from the Internet, and put it right in your gmic-qt plug-in install folder. And please tell me is you succeed, and how ! :smiley: Good luck!

PS: and of course, kudos to you for taking the time to see how the language works. It is not extremely easy to get into it :slight_smile:

1 Like

Found the missing dll in a Digikam folder, copied it and now everything works. Thanks again !!:grinning:

1 Like

Hum, that means I should also put it in the installer/zip folder.
Did you used the 32 or 64bits version of the plug-in ? Did you use the installer or the .zip file ?
Thanks!

I used the 64bit installer.

1 Like

@McCap Many thanks - much appreciated! Jules