Getting from gradient_rgb's glowing edges to a transparent-background grayscale overlay

Hi all. I’m a newbie and probably still don’t have the vocabulary down to best express what I’m after.

I’d like to exaggerate the edges of a portrait photo by taking a gradient_rgb, negating it, converting it to grayscale, darkening the dark bits, and making a layer of just those with a transparent background to place over an altered version of the original.

The first few bits are easy enough…

gmic image.jpg +fx_gradient2rgb 3,10,65,0,0,0,50,50 'negate[-1]' 'luminance[-1]' montage H

What I don’t know is how to take the dark parts of the grayscale outline and put them on a transparent background. Any tips?

Thanks.

@zedlopez Welcome to the forum! With CLI, there are many ways to achieve your goal. Sticking with what you already have, I can think of two simple ways to proceed. Before that though, why don’t you use fx_gradient_norm instead? That would save you from having to use negate and luminance.

Method 1

Since gradient norm results in white gradient lines on black you just subtract that (make sure you normalize it first n 0,255 or the suitable range) from the original. After that you cut (clip) to the proper range c 0,255 or the suitable range.

Method 2

You will need to negate the gradient norm to be black gradient lines on white. normalize both images to 0,255 or each to the suitable range then ‘blend darken’.

Edit: I write “suitable range” because the blending or subtracting depends on where the two layers are in relation to each other. You will have to adjust to your taste and image content.

Hi @zedlopez and welcome!

First of all: I am not sufficiently proficient in gmic and/or The Gimp – but still…

Do you have access to The Gimp?
How about trying this

  1. Duplicate layer
  2. Edge detect (pick suitable method) – on the new layer
  3. Top layer → Mode Multiply; opacity → 60 or thereabouts?

I have a a feeling, though, that there are much more suitable ways of dealing with your wishes using gimp-plugin-gmic.

Have fun!
Claes in Lund, Sweden

Following your exact command and just doing blend darken gives us the following. Notice the edges overlap in an unnatural way.

Original tiger

Your edge strategy

blend darken with your edge strategy


Using my command afre_edge.

gmic sp portrait9 +afre_edge 10,2 /. 2 - c 0,255

Portrait 9

Portrait 9 with afre_edge and Method 1.

I didn’t want to bog down my question with other topics, but I’m ultimately going for an illustrated b&w look; this edge exaggeration I want to try is just one thing I have in mind, so it’s not a dealbreaker that it looks bad when applied to the original image.

I liked the soft glowy effect from fx_gradient2rgb and didn’t like the faint paisley-ish details from gradient_norm. I expect there’s an incredibly simple way to make the faint lines disappear, but I don’t know it yet…

I’ve been doing lots of experimentation with the gmic plugin (and cribbing from the commands in the verbose log output). But I want to stick to learning the gmic command-line-- I ultimately want to batch process a bunch of images.

Thanks, folks.

Try searching the forum. There are plenty of threads on achieving an illustrated look and B&W processing. Sometimes like yours, the thread title doesn’t say spell it out but it is covered because we can get off topic in a good way. :slight_smile: Also take a look at the Play Raw category. Often if the source image is a portrait you get to observe what people do when they take the illustrative approach.