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. |
12th September 2015, 22:22 | #1 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
rgba_rpn/y8_rpn - RPN pixel manipulation
My new filter, rgba_rpn/y8_rpn, allows the arbitrary manipulation of pixel values from multiple clips, and can... well, it can do a lot.
Download: rgba_rpn0.1.zip Anti-virus software: it's possible that your anti-virus software may find the DLL suspicious, because it generates executable code on the fly. You'll just have to trust me Using strings in reverse Polish notation, pixel values can have all kinds of mathematical operations performed on them. It can use YUV as well as RGB clips as input (although only the Y channel of YUV clips is available), and has several different dithering modes (basically: none, ordered, or random). Please refer to the documentation and RPN guide, which are probably required reading if you want to understand the following examples. So what can it do? This is a hard question to answer, because it can do so much. You can use it to draw an anti-aliased circle: Code:
blankclip.y8_rpn("255 x w 0.5 * - dup * y h 0.5 * - dup * + sqrt 128 - 255 * -") Or a rotating (animated) anti-aliased square: Code:
blankclip.y8_rpn(" x w 0.5 * - @X^ y h 0.5 * - @Y^ 0.01 n * sincos @S^ @C^ X S * Y C * + @A^ X C * Y S * - @B^ 255 A abs 150 + B abs 150 + max - 255 * ") A more practical example - this call will desaturate any green pixels (those which have a green value greater than both red and blue): Code:
clip.rgba_rpn("[r0] 0.3 * [g0] 0.59 * [b0] 0.11 * + + [c0] [g0] [r0] [b0] max > ?") It animated-wipes (this one complete with gamma awareness and dithering): Code:
a=colorbars b=version.pointresize(a.width,a.height).trim(0,50) a=a.reduceby2 b=b.reduceby2 rgba_rpn("64 @W x W + w W + t * - \ 1 zmax pi * cos 1 + 0.5 * @A [c0] dup * * 1 A - [c1] dup * * + sqrt", 1, b, a) It sharpens (code omitted for space): It blurs: It weird blurs: And to really demonstrate the flexibility of rgba_rpn, the following example (with the help of some basic Avisynth functions) implements the w3fdif deinterlacer (discussed recently here), which was the basis for kerneldeint: Code:
mpeg2source("test.d2v") # interlaced source converttorgb24(interlaced=true) sep = separatefields odd = sep.selectodd even = sep.selecteven x = odd.blankclip(length=1) + odd.trim(0,framecount-2) y = even.trim(1,0) + even.blankclip(length=1) woven = interleave(x,y).weave rgba_rpn(" [c0] [c1] + 0.170 * [c0(0,-1)] [c0(0,1)] + 0.526 * [c0(0,-2)] [c0(0,2)] [c1(0,-2)] [c1(0,2)] + + + -0.116 * [c0(0,-3)] [c0(0,3)] + -0.026 * [c0(0,-4)] [c0(0,4)] [c1(0,-4)] [c1(0,4)] + + + 0.031 * + + + + ", last, woven,0,1) separatefields selectevery(2,1,0) interleave(last,sep) weave assumeframebased I appreciate these may be hard to understand; using RPN doesn't help when it comes to clarity! I will go through some examples in more depth in subsequent posts, if anybody wants to see them. Alternatively, I'll be happy to answer questions of the form "How would I..." Last edited by wonkey_monkey; 12th September 2015 at 22:40. |
|
|