-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gradient map filter #1046
Add gradient map filter #1046
Conversation
Some other filters already have a method for specifying color stops for a gradient. Could that method work for you? If so, it would be nice to be consistent. mlt/src/modules/qt/filter_lightshow.yml Line 65 in 335d009
|
I've tried looking into other filters but I couldn't notice how |
291f6fb
to
995a0c3
Compare
Formatted the code with clang-format. I've preferred to use |
I had to create this patch to get this code to compile.
Your implementation does not match the other filters because each color has two parts - the color and the position. Combining the values makes it more difficult for applications to use this API. Can you get by without the position? The other filters that use this method make the colors equally spaced - so a stop position is not required. |
Did you check the list of filters we get from Frei0r and avfilter to see if one of them already provide this effect? Here is a screenshot of the UI in Shotcut for the existing gradient method. If you can switch this filter to use the same method, then the code in Shotcut would be easily reused to add a UI for it. |
995a0c3
to
91eba2e
Compare
From my point of view I don't think that combining a color and a position into a pair would be too difficult, YMMV.
I'm afraid to tell that positioning is required for the gradient stops, if not some gradient configurations would be very difficult to replicate with equidistant stops. For instance in a gradient widget that controls its stops with slides if two slidables were too close it'd require lots of their equidistant counterparts to represent the same gradient, not even mentioning of what happens with even more sliders.
They do provide effects that involve gradients, but those are for overlays not mapping. The filter that resembles what gradient mapping does is
It can reuse the same widget if it supports slidable stops, else it could be modified or subclassed to suit this need. |
OK. I will not require that you implement the fixed stop positions. But then lets rename this parameter so that all the color.* parameters in MLT will have the exact same interface. I suggest to rename "color." to "stop.". Someone could add the "color." parameter as an alternate to the stop parameter. Bonus points if you also implement the fixed stop method as "color." as an alternate method to specify the gradient :)
I understand that is possible, but I think it is unlikely that a volunteer will come along to do that. |
91eba2e
to
5e75fae
Compare
Just fix these minor compile errors (debug build uses
|
5e75fae
to
eaf3177
Compare
I've ran the file with |
Great! Thanks for the merge! I'll try to see if there's a chance to use |
I do not think mlt_cache will be useful here. It is not for per-instance storage. mlt_cache is when a service has a lot to store (e.g. image) or something that is limited by the kernel (e.g. file handles). When you have many instances of the same filter in a project, it reduces the number of their internal part that is kept in memory. Consider, for example, the avformat producer has often 2 handles per object, and there can be hundreds of them in a project. Same goes for the image producers that cache the image. |
Add a new filter for gradient mapping.
filter_gradientmap
takes a frame and maps the intensity of its color to a linear gradient denoted by a list of color and position pairs separated by semicolons. Inspired by the Color Ramp node from Blender and the Gradient Map operation from image editors such as GIMP's and Krita's.The following is a demo of the filter.
Original.
Agent327.webm
A sepia photograph effect.
Agent327-sepia.webm
A thermal view effect.
Agent327-thermal.webm