Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st November 2003, 14:55   #1  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
is there a function to ADD two clips (blend)

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?
scharfis_brain is offline   Reply With Quote
Old 1st November 2003, 16:45   #2  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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

?
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 1st November 2003, 18:02   #3  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
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
scharfis_brain is offline   Reply With Quote
Old 2nd November 2003, 12:16   #4  |  Link
waka
Registered User
 
Join Date: Jul 2002
Posts: 29
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)

Last edited by waka; 2nd November 2003 at 12:21.
waka is offline   Reply With Quote
Old 2nd November 2003, 12:49   #5  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
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...

Code:
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)
	}
scharfis_brain is offline   Reply With Quote
Old 2nd November 2003, 14:22   #6  |  Link
waka
Registered User
 
Join Date: Jul 2002
Posts: 29
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:

Code:
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.

Last edited by waka; 2nd November 2003 at 14:34.
waka is offline   Reply With Quote
Old 2nd November 2003, 14:38   #7  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
LOL!
Code:
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
scharfis_brain is offline   Reply With Quote
Old 2nd November 2003, 15:17   #8  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
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.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 3rd November 2003, 12:53   #9  |  Link
mf
·
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Hmmm.. This is a very interesting one. I'll break my head over this. There must be a good way to do this.
mf is offline   Reply With Quote
Old 3rd November 2003, 15:43   #10  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
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
Wilbert is offline   Reply With Quote
Old 3rd November 2003, 16:51   #11  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 3rd November 2003, 17:28   #12  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
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!
scharfis_brain is offline   Reply With Quote
Old 3rd November 2003, 17:45   #13  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 3rd November 2003, 18:03   #14  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
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

Last edited by WarpEnterprises; 3rd November 2003 at 18:06.
WarpEnterprises is offline   Reply With Quote
Old 4th November 2003, 17:54   #15  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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 , 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
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 4th November 2003, 18:29   #16  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
Quote:
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.
Bidoche is offline   Reply With Quote
Old 4th November 2003, 19:45   #17  |  Link
mf
·
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Quote:
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.
mf is offline   Reply With Quote
Old 4th November 2003, 20:51   #18  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
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.
Wilbert is offline   Reply With Quote
Old 5th November 2003, 22:14   #19  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
Quote:
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...
WarpEnterprises is offline   Reply With Quote
Old 5th November 2003, 22:40   #20  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
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:
Quote:
- 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
In that case, the bold part is the interesting one.

- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.