image command eating channels?

When I run:
gmic +lorem 250,250 +edges 15% 40,40 gaussian. 10,4 spread. 10,0 +brushify[0] [-1],1 blur. 1,1 rm.. +image[-2] [-1],0,0,0,0,1,[-2]
I get:


I’m trying to draw the second image onto the first using the second image as a opacity mask. The output does not have color; how would I have to manipulate my image so that the opacity map preserves color channels?

Is this the result you’re looking for?

Just about, I want the black from the second image to overlay the third, like it’s outlining it.

Ok, try this:

gmic +lorem 250,250 +edges 15% 40,40 gaussian. 10,4 spread. 10,0 +brushify[0] [-1],1 blur. 1,1 rm.. +*. ..

Also, keep in mind display automatically normalize, so you might see difference between third and last image in terms of how it looks, but you can check values by overlaying your mouse yourself.

EDIT: You can use mul instead of *.

1 Like

That’s great, thanks for the help! I didn’t know you could directly multiply images; g’mic is so complex that the simple things are hard to figure out some times.

The thing to know here: Command image will draw an image over the selected images. Here, you selected [-2] which is actually [1], i.e. your binary mask (that has a single channel). So the result has a single channel too. Hence the grayscale image you get as a result.

Possible solutions for replacing +image[-2] [-1],0,0,0,0,1,[-2]:

  1. Apparenty, here you just want to “darken” the contour pixels in the blurred color image, so mul[-1] [-2] is probably what you need here.
  2. Another solution would be to extend your mask to have 3 channels : to_rgb[-2] +image[-2] [-1],0,0,0,0,1,[-2].
  3. All this works for adding black contours, but if you want to select the contour colors, it would be better to use another RGB flat image in cunjunction with the mask:
  eq[-2] 0 +fill_color. 128,64,0 image[-2] [-1],0,0,0,0,1,[-3] rm[-1]

(in that case, you need to invert the mask values to tell that pixels you want to replace are actually the pixels of the contours).

1 Like