View Full Version : is there a function to ADD two clips (blend)
scharfis_brain
1st November 2003, 14:55
I want to add two clips together by blending them. but the layer-command normalizes the lightness. I want the lightness increasing when adding two clips together.
In the Moment I am using this:
a=????
b=????
c=subtract(converttorgb32(a),invert(converttorgb32(b),"RGBA"))
but this is not very fast since there are two colorspace conversions and one inversion....
is there another way to solve it?
Didée
1st November 2003, 16:45
Scharfi,
what the hell are you doing there? :)
Your script gives me sort of an psychedelic-solarized picture, which doesn't give me the impression of being too useful. (Using Avisysnth Oct11, feeded with yv12.)
Are you aiming for an effect only, or do you want to perform a detection-of-something?
To do something *similar* to what you told (adding with increasing lightness), what about
a=whatever.levels(0,1.0,255,255,0)
b=whatever.levels(0,1.0,255,255,0)
layer(a,b,"mul")
levels(0,1.0,255,255,0)
Not really adding, but inverse-multiplying.
In order to avoid 16-235 limiting, use YV12layer from Kurosu's MaskTools instead.
- Didée
P.S.
BTW, is there a clamping filter out there somewhere?
i.e. WannaClamp(32,224) ==> [0-31] == black, [32-224] == original, [225-255] == BLACK
?
scharfis_brain
1st November 2003, 18:02
oh, I have written this expamle script without testing...
now I am using
a=whatever
b=whatever.levels(0,1,255,255,0)
subtract(a,b)
and, no, I don't want these terrible color-effects, I just want a clean addition of two clip, "mul" wasn't suitable
btw.: can you reproduce this strange thing:
try to resize a clip with pointresize to exactly its third horizontal size. I am always getting a black or green picture..
example:
video has 768,576 pixels
pointresize(256,576) ---> returns garbage
waka
2nd November 2003, 12:16
Speaking from a yuv perspective.
Layer will average the two clips or (a+b)/2. Multiply the resulting values by two and you get the clips "added together".
a=????
b=????
layer(a,b,"fast")
coloryuv(gain_y=256,gain_u=256,gain_v=256)
However, chroma values are relatively close to 128 usually, so if you add them together you'll likely end up with values 200+ which will be a purple/orange mess. Also, "black" can have a significant luma value, ~16. Adding two "black" clips can result in a dark grey. Without knowing what you are trying to accomplish, the following might be suitable.
a=????
b=????
layer(a,b,"fast")
coloryuv(off_y=-16)
coloryuv(gain_y=256)
coloryuv(off_y=16)
scharfis_brain
2nd November 2003, 12:49
I am trying to imitate the cleartype-smoothing of WinXP using AVIsynth, because some time ago there was a tool out htere, that was able to resize images this way. But now this tool (clearscale) is unfindable.
My attempt is, to separate a picture in its three color componentes (RGB) and then add them back together.
But Layer is IMO unacceptable, becaue it reduces the quantisation to 128 levels...
function clearscale(clip i, int breite, int hoehe)
{
converttorgb32(i)
bicubicresize((breite*3),hoehe).addborders(0,0,3,0)
x=generalconvolution(0,"
0 0 0 0 0
0 0 0 0 0
1 2 6 2 1
0 0 0 0 0
0 0 0 0 0")
R=crop(x,0,0,-3,0).
\pointresize(breite*6,hoehe).pointresize(breite,hoehe).
\RGBadjust(1,0,0,1)
G=crop(x,1,0,-2,0).
\pointresize(breite*6,hoehe).pointresize(breite,hoehe).
\RGBadjust(0,1,0,1).levels(0,1,255,255,0)
B=crop(x,2,0,-1,0).
\pointresize(breite*6,hoehe).pointresize(breite,hoehe).
\RGBadjust(0,0,1,1).levels(0,1,255,255,0)
subtract(subtract(R,G),B)
}
waka
2nd November 2003, 14:22
Interesting project.
Don't know why I didn't think of using rgbadjust, certainly makes more sense.
If the artifacts that subtract sometimes has bothers you, try:
R=crop(x,0,0,-3,0).pointresize(breite*6,hoehe).
\pointresize(breite,hoehe).RGBadjust(1,0,0,1)
G=crop(x,1,0,-2,0).pointresize(breite*6,hoehe).
\pointresize(breite,hoehe).RGBadjust(0,1,0,1)
B=crop(x,2,0,-1,0).pointresize(breite*6,hoehe).
\pointresize(breite,hoehe).RGBadjust(0,0,1,1)
layer(r,g,"fast").layer(b,"add",85).rgbadjust(3,3,3,1)
Thats quite close to the subtract version, with a little tweaking of the final rgbadjust you might get a good match.
Edit: I suppose it is a trade off between subtract artifacts and the quantisation issues as you said.
scharfis_brain
2nd November 2003, 14:38
LOL! layer(r,g,"fast").layer(b,"add",85).rgbadjust(3,3,3,1)
this was my first attempt when writing this script.
the only difference was that I used levels(0,1,85,0,255) instead of rgbadjust(3,3,3,1).
But your solution has the same problem: quantisation reduction by 3! you'll end up with only 85 greyscale-steps out of 255 possible.
That's, why I am using a invertion with levels and then the subtract-function. I never had artifacts using it this way. But a pure add(clip,clip) - function would be much better
Mug Funky
2nd November 2003, 15:17
i second the request for maths operations in avisynth...
it shouldn't be hard to extend layer to support a butload of math ops (RGB32 mostly, because the maths only really works properly there). i'd love to be able to do difference and multiply (PROPER multiply, like photoshop does).
bah. i totally wish i knew c programming. could just lift some bits out of the GIMP and put them into avisynth.
mf
3rd November 2003, 12:53
Hmmm.. This is a very interesting one. I'll break my head over this. There must be a good way to do this.
Wilbert
3rd November 2003, 15:43
BTW, is there a clamping filter out there somewhere?
i.e. WannaClamp(32,224) ==> [0-31] == black, [32-224] == original, [225-255] == BLACK
This is easy to make. Do you still need it? Even mf can make it, if he gets VC++ somewhere :)
Didée
3rd November 2003, 16:51
Wilbert:
Yes, I still would need that clamping thingy.
I already assumed that it should be relatively easy to implement ... but I never used any compiler in the past 12 years ;) -- and simulating this operation all the time with 'layer' slows down things unnecessarily.
If someone could do that little filter, it would be appreciated very much!
BTW, the goal is to perform some free curve adjustments, like we are used to deal with in graphic programs. E.g. take the lighness as input, and adjust it so that e.g. 0-->0, 64-->255, 255-->0, with smooth transitions, like spline.
If someone could do a filter like *that* -- /me starts dreaming.
Actually, I'd need the clamping only as a means to do something like mentioned above. Although I can also think of some other useful things to do with clamping. Basically, it means isolating ranges or bands of lightness, and that could come handy if you think about it.
- Didée
scharfis_brain
3rd November 2003, 17:28
What the hell is a clamping-filter?
Are you talking about a LUT (Lookup table) - Filter?
like this: http://home.arcor.de/scharfis_brain/samples/curves.png
If yes, I would like to see it in AVIsynth, too!
Didée
3rd November 2003, 17:45
A picture says more than a thousand words - yes.
As long as we don't have it, it's possible to simulate something similar with clamping, adjusting gamma, and shifting around. For simple tasks, that could suffice.
WarpEnterprises
3rd November 2003, 18:03
give me some hints on how
- the parameters (linear, spline, each point,...)
- the channel handling (always equally,...)
- useful in YUY/RGB
- some example purposes
could be.
Would be really easy (if you don't insist on assembly lang)
But only for ONE source.
Layer is something completely different.
...maybe conditionally changing depending on the current brightness :p
Didée
4th November 2003, 17:54
Hmmmm...
For the parameters, perhaps like
WarpEnterprisesIncredibleNewCurveAdjustmentFilter( \
type="line"|"stairstep"|"spline" \
x1=0,y1= ..., xn=255,yn=128 )
Or is there a more elegant solution to give the control points to the filter? Good question ...
Channel handling:
Well, for me, handling of Y only would suffice completely. But I'm sure mf would tell a completely other story ;)
Color spaces:
All available, of course :p , and especially the non-existant 16-bit greyscale color space! That and nothing else!! :)
Purposes:
What about
- denoising a clip
- detect image features/detail (edges)
- make a mask that covers only very weak detail, but not the "flat" areas, and also not the strong edges
=> sharpen the weak detail, whilst introducing very little new noise, and not over-sharpening of the already prominent features?
Or simply
- enhance contrast, with less loss in dark/bright areas than by the usual levels command?
Or perhaps
- simple-to-achieve masking of dark-only or bright-only areas?
Of course, a *cough*working*cough* "coring" option in "levels" would also come handy then ...
- Didée
Bidoche
4th November 2003, 18:29
and especially the non-existant 16-bit greyscale color space! You want that one with 16 bits depth ?
The one I imagined (and still not completed) was 8 bit only.
mf
4th November 2003, 19:45
Originally posted by Wilbert
This is easy to make. Do you still need it? Even mf can make it, if he gets VC++ somewhere :)
Poor student as I am, I would never be able to *cough* afford that, especially not TWO *cough* versions with *COUGH* the entire CD collection *snort* AND a special *cough* SDK that *whiff* requires registration with Microsoft.
Wilbert
4th November 2003, 20:51
WarpEnterprisesIncredibleNewCurveAdjustmentFilter( \
type="line"|"stairstep"|"spline" \
x1=0,y1= ..., xn=255,yn=128 )
Or is there a more elegant solution to give the control points to the filter? Good question ...
An other option is to specify the curve explicitly (as function + domain). But I don't know whether that is easier for the user.
WarpEnterprises
5th November 2003, 22:14
function + domain
you mean specifying the FUNCTION as string?
the domain is then mapped to 0-255.
so it would be e.g.:
WinCaf(clip, "sin" , 0.0, 2*3.1415)
or maybe better:
specifying each channel as :
WinCaf(clip, Y="spline(Y, 0,0, 255,255)"
@Didée: what I don't see is how to use THAT for denoising,etc.
And of course it is OT as scharfis_brain wanted more Layer ops, which are hopefully possible when Richard makes it.
It may take a while as I'm playing around with my hardware...
Didée
5th November 2003, 22:40
what I don't see is how to use THAT for denoising There you are not alone: I've not the slightest clue how to use that for denoising :)
... that one idea was not for denoising, but after denoising:
- denoising a clip
- detect image features/detail (edges)
- make a mask that covers only very weak detail, but not the "flat" areas, and also not the strong edges
=> sharpen the weak detail, whilst introducing very little new noise, and not over-sharpening of the already prominent featuresIn that case, the bold part is the interesting one.
- Didée
WarpEnterprises
10th November 2003, 23:22
try it:
look here under Adjust (http://www.avisynth.org/users/warpenterprises/)
AdjustY(clip, string "Y", bool "eval_frame")
"Y" is the formula string for the NEW Y and must use the variable Y (which represents the OLD Y) and can use N as current frame if eval_frame is TRUE.
I think it does what was proposed.
eval_frame=TRUE is quite slow,
but you can e.g. make FX like wobbling the luma:
AdjustY("Y+100*sin(N/2)", true)
maybe you report some results.
Works with AviSynth 2.5x, RGB32/RGB24/YUY2
Wilbert
10th November 2003, 23:27
The plugin is not listed in your table ?
WarpEnterprises
11th November 2003, 10:59
oops, uploaded ZIP but forgot the index page...
this link should work (http://www.avisynth.org/users/warpenterprises/files/adjust_25_dll_20031110.zip)
Mug Funky
11th November 2003, 15:26
hmm. if we're porting photoshop-style filters to avisynth, wouldn't it make sense to define the curves by just loading one of those photoshop curves preset files?
they're *.acv files or something. it'd be kool to bring a still into photoshop, tweek the curves, save a preset then import that into avisynth.
personally, if i could do that in avisynth i will have very few reasons to use after effects at all...
WarpEnterprises
11th November 2003, 21:12
sorry, I don't have photoshop.
can you send me some examples, maybe the files can easily be parsed.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.