Color erase like GIMP
Background: I have created an animation with animejs, using some SVG images. Not knowing how I could render those I have done a screen capture using ffmpeg on a green background. Suggestions on which renderer would be capable in rendering on top an transparent surface would be interesting. What I want: What I would like to achieve is to use the green channel as alpha mask, but it should also do partial transparency while maintaining the input color. Within GIMP I am able to apply color-erase to replace the green background to transparency, ImageMagick is not able to do it. Cinelerra and ffmpeg also seem to mask, but not subtract. An alternative script is capable of creating an alpha for green, but not keeping the original input white, like GIMP. In ./app/operations/layer-modes/gimpoperationlayermode-blend.c the function gimp_operation_layer_mode_blend_color_erase describes the inner working. Could anyone suggest how to achieve this within Cinelerra or first with an external tool? -- Stefan
I don't know how animejs works and I think it is a pity you can not make a render with it (and using alpha channel). In Cinelerra-GG there are "Chroma key" and "Chroma key (HSV)" plugins for that but may be it doesn't work very well for your goal. "Chroma key (HSV)" plugin is very powerful but you need to work on it to achieve a good output. IgorBeg Il 26/09/2021 01:38, Stefan de Konink via Cin ha scritto:
What I would like to achieve is to use the green channel as alpha mask, but it should also do partial transparency while maintaining the input color.
On Sunday, September 26, 2021 11:58:42 AM CEST, Igor BEGHETTO via Cin wrote:
I don't know how animejs works and I think it is a pity you can not make a render with it (and using alpha channel). In Cinelerra-GG there are "Chroma key" and "Chroma key (HSV)" plugins for that but may be it doesn't work very well for your goal. "Chroma key (HSV)" plugin is very powerful but you need to work on it to achieve a good output.
The problem with Chroma key HSV is that it will clamp a light green color to 'white' and not 'white+transparant'. At least that is my experience last night. I am still interested (and motivated) to see the Color Erase happen by the algorithm GIMP uses. I have found that ffmpeg has a blend filter, but subtract is not equal to color erase. What I have done during the early hours. I have implemented a QML Webkit based browser. I am able capture the onscreen RGBA surface (yes, really...) but because this is a single threaded effort I cannot do that at the 'native' speed to PNG. So I multiplied all the timing by 10, and captured at 2.5fps, this gives me: <http://stefan.konink.de/proRes444_output.mov> -- Stefan
It seems pretty good. For you, is it the right way? Il 26/09/2021 13:47, Stefan de Konink via Cin ha scritto:
What I have done during the early hours. I have implemented a QML Webkit based browser. I am able capture the onscreen RGBA surface (yes, really...) but because this is a single threaded effort I cannot do that at the 'native' speed to PNG. So I multiplied all the timing by 10, and captured at 2.5fps, this gives me: <http://stefan.konink.de/proRes444_output.mov>
On Monday, September 27, 2021 10:45:55 AM CEST, Igor BEGHETTO via Cin wrote:
It seems pretty good. For you, is it the right way?
I think it would be more suitable to build a way to 'frame sync' webkit. My idea would be to see if it is possible to provide an external world clock / tick. The ability to screenshot... that could have massive impact for anything that looks good in a browser and could be used in professional production outside the realm of more specialistic tools. I am also trying to understand the GIMP Color Erase work, because I am unable to reach the same output values. -- Stefan
On Monday, September 27, 2021 10:45:55 AM CEST, Igor BEGHETTO via Cin wrote:
It seems pretty good. For you, is it the right way?
I got it to work under FFmpeg as well, code quality is still subpar... but in general I would love to have thing thing natively in Cinerella as well. The variant with a single color make sense, but also subtracting another layer. <https://github.com/skinkie/FFmpeg/commit/7683c206446661e04bfc34b0149cbcf4c19a3d55#diff-30bbbdaad37f440707bda666ec8c00a0c3d6812cc62a54a873bcb16ea7487bd3R690> -- Stefan
On Monday, September 27, 2021, Stefan de Konink via Cin < [email protected]> wrote:
On Monday, September 27, 2021 10:45:55 AM CEST, Igor BEGHETTO via Cin wrote:
It seems pretty good. For you, is it the right way?
I got it to work under FFmpeg as well, code quality is still subpar... but in general I would love to have thing thing natively in Cinerella as well. The variant with a single color make sense, but also subtracting another layer.
<https://github.com/skinkie/FFmpeg/commit/7683c206446661e04b fc34b0149cbcf4c19a3d55#diff-30bbbdaad37f440707bda666ec8c00a0 c3d6812cc62a54a873bcb16ea7487bd3R690>
well, if you have patch for ffmpeg (relatively new version) you can also patch Cinelerra-gg's internal copy of ffmpeg and try your filter from there, or add it as new blending mode as I tried (for other equations) some time ago (hack attached)
-- Stefan
On Tuesday, September 28, 2021 8:21:58 AM CEST, Andrew Randrianasulu via Cin wrote:
well, if you have patch for ffmpeg (relatively new version) you can also patch Cinelerra-gg's internal copy of ffmpeg and try your filter from there, or add it as new blending mode as I tried (for other equations) some time ago (hack attached)
In my own cinGG ff_blend is not available as plugin. So... need to figure out that part first. In addition; I was already warned that my code would cause issues on 420 formats. Should check that too. -- Stefan
On Tuesday, September 28, 2021, Stefan de Konink via Cin < [email protected]> wrote:
On Tuesday, September 28, 2021 8:21:58 AM CEST, Andrew Randrianasulu via Cin wrote:
well, if you have patch for ffmpeg (relatively new version) you can also patch Cinelerra-gg's internal copy of ffmpeg and try your filter from there, or add it as new blending mode as I tried (for other equations) some time ago (hack attached)
In my own cinGG ff_blend is not available as plugin. So... need to figure out that part first.
In addition; I was already warned that my code would cause issues on 420 formats. Should check that too.
aw, sorry, it commented out as having i/o errors :( http://git.cinelerra-gg.org/git/?p=goodguy/cinelerra.git;a=blob;f=cinelerra-... I was thinking about reroute plugin in addition to chromakey, but probably this still does not do what you want.. "The Reroute plugin enables you to selectively transfer the Alpha channel or the Components (RGB or YUV) or both from a source track to a target track, partially overwriting the target's contents. It works as a shared plugin." https://cinelerra-gg.org/download/CinelerraGG_Manual/Reroute.html
-- Stefan -- Cin mailing list [email protected] https://lists.cinelerra-gg.org/mailman/listinfo/cin
On Tuesday, September 28, 2021 3:11:09 PM CEST, Andrew Randrianasulu via Cin wrote:
I was thinking about reroute plugin in addition to chromakey, but probably this still does not do what you want..
"The Reroute plugin enables you to selectively transfer the Alpha channel or the Components (RGB or YUV) or both from a source track to a target track, partially overwriting the target's contents. It works as a shared plugin."
https://cinelerra-gg.org/download/CinelerraGG_Manual/Reroute.html
My problem generally with these things: 1. chromakey does not seem to be able to do half-transparency, it can make it fully the full color, without alpha... 2. alternative approaches make the half transparent areas a lighter green color. I have tested reroute and chromakey. I might have over looked that the source layer I am working on was RGB24 and not RGBA. So it might be required that such plugin first does a pixel format conversion. -- Stefan
In order to have a half transparency you could try to use Blue Banana (see https://cinelerra-gg.org/download/CinelerraGG_Manual/Blue_Banana.html). Then use Reroute plugin . I've often tried to create a track with only the alpha channel that I could manipulate independently and then merge via overlays, also using the F_separatefields plugin; but I've never succeeded. Last tip: when dealing with the alpha channel it can be convenient to render a sequence of png (or OpenEXR) instead of just video formats.
Good, Stefan! As said by Andrew, it would be fine to have this feature like a new plugin in Cinelerrra-GG, if possible. So, if that plugin had some problem, it would be confined there. IgorBeg Il 27/09/2021 13:01, Stefan de Konink via Cin ha scritto:
I got it to work under FFmpeg as well, code quality is still subpar... but in general I would love to have thing thing natively in Cinerella as well. The variant with a single color make sense, but also subtracting another layer.
In addition; I was already warned that my code would cause issues on 420 formats. Should check that too.
participants (4)
-
Andrea paz -
Andrew Randrianasulu -
Igor BEGHETTO -
Stefan de Konink