I would like to convert a grayscale image to a smooth transparent image.(opacity depends on blackness)
but, I have no idea about filter names. (I searched alpha, transparent, convert but I can’t find)
which filter can achieve this effect?

I would like to convert a grayscale image to a smooth transparent image.(opacity depends on blackness)
but, I have no idea about filter names. (I searched alpha, transparent, convert but I can’t find)
which filter can achieve this effect?

Is it with the plug-in or with the command line tool ?
thank you for reply.
I use command prompt this time.
I would like to make my daily routine to .gmic custom code.
so, filters combination is also ok.
Perhaps:
gmic run '256,256,1,1,255*x/(w-1) +fill iM-i append c display0'
The useful bit is +fill iM-i append c That is, make an alpha channel from the inverse of the given grayscale; such is then appended to the given grayscale along the spectral (channel) axis. display0 just confirms if the scheme works, and 256,256,1,1,255*x/(w-1) makes a black-to-white ramp as a test grayscale image.
With a single channel image. You can do foreach { +negate 255 append c } to do it for every single-channel grayscale image. In general, built-in processing commands are much faster than JIT commands.
Thank you all! I can convert the gray image to smooth alpha😃
But, I found one odd behavior.
When I run below script, output is fine, but “display” command show me this another preview in G’MIC-Qt stand-alone interface.
Is it only my environment?
foreach {
to_rgb
fx_blackandwhite 0.299,0,0.587,0,0.114,0,0,0,0,0,0,0,0,0,2,0,0,0,16,4,0,0,0,50,50
to_gray
+negate 255
append c
display
}
Thank you! I can see right preview now.
May I ask what is the difference between negate and negate 255 ?
Negate by itself automatically use the maximum value instead of 255. That’s the main difference.
memo about display, future reference.
Alas, this display tutorial cheat has suffered bit-rot more than most. The issue it raises (lying about normalization) has been well addressed by the current implementation through the ‘n’ key. See display.
Consider:
gmic run '256,256,1,4,lerp([100,0,0,255],[0,100,100,255],y/(h-1)) -ellipse 128,128,50,50,0,0.3,255,0,200'
At the outset, display provides a normalized image, in line with the tutorial’s complaint:

Normalization on
but in the current display The n key toggles through a number of normalization modes. Pressing n once toggles normalization off, thereby getting a “truthful” display:

Normalization off
This toggle key removes the basis of this cheat’s complaint.
In a few weeks (methinks) this rather radioactive cheat will be replaced with something less misleading (and a different topic). Advice to those helicoptering in that the link will be retired. Sorry for the disruption.