View Full Version : MVTools, Depan, DepanEstimate for VapourSynth
Pages :
1
2
3
4
[
5]
6
7
8
9
10
foxyshadis
18th June 2015, 07:12
One problem is that if you tried that extreme exposure shift with an 8bit input, there would be any details to lead to banding -- it'd be one solid flat white or black with a few sprinkles of color here and there. 3dsmax starts with 64bit and downconverts (with lousy dithering IMHO) from there; it doesn't start with 8bit and work up. What you start with is far more important for your process than what you could do with it under perfect conditions.
If you're creating ultra-high-bit CGI, then you shouldn't need to apply extreme grading or filtering: That should be part of the generating process.
Like I said, float has a tangible and very valuable benefit over int -- the whole universe is its gamut, and you never have to worry about clipping, unless you routinely work with infinity. Even float16 is sufficient for conversion to int8 or int10, but since there's zero hardware or SIMD support for it, there's no point in saving a little memory for a lot of cpu time anymore. Likewise, int16 linear can uniquely represent all but maybe one or two of the bottom int10 gamma corrected values, so it is enough for any practical purpose (encoding). And if you get too hung up on roundoff errors, pretty soon you start wanting doubles or even quads.
Honestly, when it comes to filters directly associated with color control and grading, float32 support is damn handy, but I just can't see any point to it for destructive filters (like denoisers).
feisty2
18th June 2015, 07:56
I'm not grading or filtering CGI, it's just, I found 16bpc can actually be, not enough in some cases, I had used to think 16bpc should be enough for almost everything, and that 3dsmax incident refreshed my mind, so a new level of "enough for everything", float32, replaced 16bits stuff in head
and naturally, I want all 16bits stuff degraded and take float32 instead, for, first, it can get the most hardass situation handled, and it's more mathematically correct, that's a bonus
should I just be okay with 16bpc, I'm in the middle of mvtools modification
Bloax
18th June 2015, 14:41
?That 3ds Max incident where you did the equivalent of squishing a 0-255 range into 0-1 and then getting imperfections when stretching it back to 0-255 reminded you of the fact that you need more precision despite this never happening in the wild?
feisty2
18th June 2015, 15:56
that kind of thing could happen, extreme like that, maybe rare, milder version, very common actually, say, every step introduces some errors, <= 0.5/65536 at int16, literally "very small" errors, but that's just ONE step, what happens if you got a process chain, right, errors will accumulate , they will grow fatter and fatter gradually, and finally, they won't just be there as "small" errors, they will become large errors, if you just got operations like +/-, errors might stay small, now imagine, what about operations like ^, exp, log
captainadamo
18th June 2015, 16:08
Can you actually show us visual results of these "errors" you are spending huge amounts of time to get rid of? Maybe if you can actually demonstrate a need for this using a real-world sample, not something contrived in order to exaggerate, someone may be more willing to put in the work. All you've done so far is talk about theoreticals and vagaries but no actual examples.
Edited to add: It just seems that your effort would be better spent trying to mitigate these errors through other means rather than trying to hamfist in support for some other format into a codebase that is at best an opaque wall of code even for people who know C or C++ well. Let alone for someone who admits that they are basically a novice.
feisty2
18th June 2015, 16:40
I never had serious problems with int16 in regular cases so far, things are pretty extreme when int16 fails, then you might think they are "contrived in order to exaggerate", but I'm doing this like an insurance, it will surely save my ass whenever shit happens, maybe that's rare, but it won't bite in regular cases, and you even got some tiny bonus like "more mathematically correct"
Reel.Deel
18th June 2015, 16:45
I think you might be overreacting, look at QTGMC, it's all 8-bit processing and the result looks fantastic. I would be a little bit more understanding If your source was actually truly high bit depth. Anyways I think this discussion has gone off topic...
captainadamo
18th June 2015, 16:56
I never had serious problems with int16 in regular cases so far, things are pretty extreme when int16 fails, then you might think they are "contrived in order to exaggerate", but I'm doing this like an insurance, it will surely save my ass whenever shit happens, maybe that's rare, but it won't bite in regular cases, and you even got some tiny bonus like "more mathematically correct"
Then have fun with that. You do realize that all you're going to do is make all your scripts with mvtools be even slower than they already are, right? Especially if you start removing asm code like you mention above. Is likely a 2 or 3 fold increase in processing time for the mvtools part of your script really going to be worth fixing rounding errors you admit you've never actually seen make visible problems? It's your time to waste as you want...
feisty2
18th June 2015, 17:06
I changed my mind hours ago (when Myrsloik confirmed he won't add float to rgvs/core soon) actually, I'm starting with simple filters like removegrain
feisty2
23rd August 2015, 11:02
so I'm floatizing MVTools and actually not that hard like I thought it would be
https://github.com/IFeelBloated/MVTools-Float
just floatized mv.Super and working on mv.Analyze
feisty2
25th August 2015, 03:54
where did you scale SAD values calculated from clips with different bit depths to the same level (like default thsad=400 works almost the same on uint8_t and uint16_t)?
I got float SADs returned by Sad_C and how do I make it that "400" kind of stuff?
edit: never mind, just found out they are scaled inside each individual client functions, not mv.Analyze...
edit2: Do I have to store the float SAD as bytes inside VECTOR struct and restore it back to float when I read it?
feisty2
26th August 2015, 16:24
@jackoneill
2 parameters (lambda and global) in mv.analyse are actually unusable, as they are internally occupied by Python, guess you'll have to rename them
jackoneill
26th August 2015, 17:30
@jackoneill
2 parameters (lambda and global) in mv.analyse are actually unusable, as they are internally occupied by Python, guess you'll have to rename them
https://github.com/vapoursynth/vapoursynth/blob/master/doc/pythonreference.rst#python-keywords-as-filter-arguments
feisty2
27th August 2015, 03:12
ah, didn't know that before, thx for the tip
feisty2
29th August 2015, 06:07
SATD(C version) for 16 * X blocks is broken I guess
jackoneill
29th August 2015, 09:25
SATD(C version) for 16 * X blocks is broken I guess
You guess? Or do you know for sure and can point out the problem?
feisty2
29th August 2015, 09:31
You guess? Or do you know for sure and can point out the problem?
I'm sure, I can't point the problem out cuz I don't really get how that code works actually
but the result is very different from the avisynth mvtools, so it has to be broken
feisty2
29th August 2015, 09:53
@jackoneill
xxx
clp=last
sup = MSuper(clp)
bv1 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
fv1 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
bv2 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
fv2 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
bv3 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
fv3 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
MDegrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=2000, thscd1=10000)
converttoy8 ()
http://i.imgur.com/q4J3uk0.png
import vapoursynth as vs
core = vs.get_core()
clp = xxx
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=32, flt=True)
clp2 = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=16)
sup = core.mvsf.Super(clp)
bv1 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
fv1 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
bv2 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
fv2 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
bv3 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
fv3 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
clp = core.mvsf.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=2000, thscd1=10000)
sup2 = core.mv.Super(clp2)
bv12 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
fv12 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=5)
bv22 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
fv22 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=5)
bv32 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
fv32 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=5)
clp2 = core.mv.Degrain3(clp2, sup2, bv12, fv12, bv22, fv22, bv32, fv32, thsad=2000, thscd1=10000)
clp2 = core.fmtc.bitdepth(clp2, fulls=True, fulld=True, bits=32, flt=True)
fnl = core.std.StackHorizontal([clp,clp2])
fnl.set_output ()
http://i.imgur.com/zg2jNMM.png
jackoneill
29th August 2015, 10:38
I'm sure, I can't point the problem out cuz I don't really get how that code works actually
but the result is very different from the avisynth mvtools, so it has to be broken
Then how did you fix it?
feisty2
29th August 2015, 10:44
Didn't fix it, more of "rewrote it"
The 4x4 SATD works so I just extended it to 8x8 16x16 and 32x32
feisty2
30th August 2015, 06:07
@jackoneill
Did some more tests, your 16x16 SATD works at uint8_t but fails at uint16_t
feisty2
30th August 2015, 15:01
import vapoursynth as vs
core = vs.get_core()
clp = xxx
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=8)
sup = core.mv.Super(clp)
bv1 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
fv1 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
bv2 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
fv2 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
bv3 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
fv3 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
clp = core.mv.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=1200, thscd1=10000)
clp.set_output ()
http://i.imgur.com/bD7wHO9.png
import vapoursynth as vs
core = vs.get_core()
clp = core.d2v.Source ("D:/CIMW/VID.d2v")
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=16)
sup = core.mv.Super(clp)
bv1 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
fv1 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
bv2 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
fv2 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
bv3 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
fv3 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
clp = core.mv.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=1200, thscd1=10000)
clp.set_output ()
http://i.imgur.com/DHd7096.png
don't wanna be an asshole here, but...
dct=1-4 for uint16_t are broken as well...
and I pulled a request on GitHub that should have fixed dct=5-10 for uint16_t by the way
but I got no idea how to fix this... so good luck with it
jackoneill
30th August 2015, 15:20
import vapoursynth as vs
core = vs.get_core()
clp = xxx
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=8)
sup = core.mv.Super(clp)
bv1 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
fv1 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
bv2 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
fv2 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
bv3 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
fv3 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
clp = core.mv.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=1200, thscd1=10000)
clp.set_output ()
http://i.imgur.com/bD7wHO9.png
import vapoursynth as vs
core = vs.get_core()
clp = core.d2v.Source ("D:/CIMW/VID.d2v")
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=16)
sup = core.mv.Super(clp)
bv1 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
fv1 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=1,search=3,truemotion=True,dct=1)
bv2 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
fv2 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=2,search=3,truemotion=True,dct=1)
bv3 = core.mv.Analyse(sup,isb=True,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
fv3 = core.mv.Analyse(sup,isb=False,blksize=8,overlap=4,delta=3,search=3,truemotion=True,dct=1)
clp = core.mv.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=1200, thscd1=10000)
clp.set_output ()
http://i.imgur.com/DHd7096.png
don't wanna be an asshole here, but...
dct=1-4 for uint16_t are broken as well...
and I pulled a request on GitHub that should have fixed dct=5-10 for uint16_t by the way
but I got no idea how to fix this... so good luck with it
Can you also post the same frame without any filtering?
feisty2
30th August 2015, 15:34
import vapoursynth as vs
core = vs.get_core()
clp = xxx
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp.set_output ()
http://i.imgur.com/dgRukz3.png
YAFU
3rd September 2015, 00:26
Hello.
I post in this thread because I think my problem is related to mv tools (I've seen something like this script is used on page 8).
The user "brothermechanic" from blenderartists forum has published a script to reduce noise from videos made with Blender 3D renderings (Cycles engine):
http://www.blenderartists.org/forum/showthread.php?378736-Cycles-noise-reduction-with-VapourSynth
I'm using VapourSynth under Linux. Noise reduction is good, but there are problems with color banding. In some cases the banding is very noticeable. Here I share a set of images. In the video you can see the banding in the red walls and spheres:
https://www.dropbox.com/s/6miemtkv9a8q018/BlenderCycles-VapourSynth.zip?dl=0
I am not a programmer, I have no idea of scripting, so I'm a bit stuck here. So I would appreciate if you can take a look at the script and images, and if you can recommend me how to prevent the banding is so visible. Maybe we are doing something wrong with this script?
I know there are filters to debanding, but apparently they add noise to the image, and our main goal here is to remove the noise. So it would be great if you could recommend a better option to solve that problem.
I am making the video with this from terminal:
vspipe --y4m script.vpy - | ffmpeg -i pipe: -vcodec libx264 -crf 10 encoded.mkv
PS: I guess that people with little knowledge of the issues discussed in this forum (like me) are not very welcome, because the random questions are very difficult...
MonoS
3rd September 2015, 01:53
You're welcome here :)
Sorry for the rushed reply but it's 2am and i'm from my phone :p
www.pasteall.org/60924/python
Banding when using a denoising script is caused by processing thr image at a bitdepth too low, i modified the paste so that it use a 16bit pipeline [hoping that FT3dfilter support it].
I've also lowered the number of reference for motion estimation cause i've find degrain3 to strong.
Thsad of 400 is pretty high, try to use a lower value, something like 200,
Also i think you save your original blender render in jpg, don't do that, save it in png, even better if on png48, i've never used blender so i can't help you here.
Last tip, if the video you save is a temporary one to be reprocessed you can use a 10bit build of x264 on lossless mode [crf=0] and outputting a 4:4:4 video [--output-csp i444], or save it in png48 using imwri.write()
If it is the final render then let me know and wait utc 12:00 and i'll expand my explaination
Let me know if you have questions :)
feisty2
3rd September 2015, 02:18
Fft3d supports 8bits only
YAFU
3rd September 2015, 04:24
@MonoS, thank you for answer in those late hours of the night!
When using "png" the same banding is also generated. Blender supports many output formats and also 16 bits. So, is there some "Fft3d" alternative with 16 bits support (for vapoursynth)? I have seen that there is "Fft3dgpu"? Is that filter for vapoursynth and with 16-bit support? Generally Blender/Cycles users have high end GPU's.
feisty2
3rd September 2015, 04:29
dfttest (category wise, both are frequency denoisers)
but these 2 are pretty destructive to high frequencies, you got some better options actually, like KNLMeansCL
and it even works at 32bits precision (floating point)
YAFU
3rd September 2015, 05:18
Thank you. I compiled and installed "KNLMeansCL" in linux (need to install "opencl-headers", but I'm not sure if it will work because I use "nvidia" proprietary driver ).
But I have no idea how to implement or adapt the script. Where could I find any examples on how to use it?
feisty2
3rd September 2015, 05:20
http://forum.doom9.org/showthread.php?t=171379
feisty2
3rd September 2015, 05:48
example
import vapoursynth as vs
core = vs.get_core()
clp = core.imwri.Read('png-50/%04d.png', firstnum=1, alpha=False)
clp = core.fmtc.bitdepth (clp, bits=32, fulls=True, fulld=True, flt=True)
clp = core.fmtc.matrix (clp, mat="601", fulls=True, fulld=True)
def getvectors (src, pelclip, tr=6, pel=4, dct=0, thsad=400):
core = vs.get_core ()
src16 = core.fmtc.bitdepth (src, fulls=True, fulld=True, bits=16, flt=False)
supersoft = core.mv.Super (src16, pel=pel, chroma=False, hpad=32, vpad=32, pelclip=pelclip, sharp=2, rfilter=4, levels=0)
supersharp = core.mv.Super (src16, pel=pel, chroma=False, hpad=32, vpad=32, pelclip=pelclip, sharp=2, rfilter=2, levels=0)
def search (isb, delta):
vectors = core.mv.Analyse (supersoft, isb=isb, overlap=16, blksize=32, search=3, chroma=False, truemotion=True, delta=delta, trymany=True, searchparam=16, pelsearch=16, dct=dct, levels=0, divide=2, badrange=-24)
vectors = core.mv.Recalculate (supersoft, vectors, overlap=8, blksize=16, thsad=thsad//2, chroma=False, truemotion=True, search=3, searchparam=16, dct=dct, smooth=1, divide=2)
vectors = core.mv.Recalculate (supersharp, vectors, overlap=4, blksize=8, thsad=thsad//2, chroma=False, truemotion=True, search=3, searchparam=16, dct=dct, smooth=1, divide=2)
vectors = core.mv.Recalculate (supersharp, vectors, overlap=2, blksize=4, thsad=thsad//2, chroma=False, truemotion=True, search=3, searchparam=16, dct=dct, smooth=1, divide=0)
return vectors
bv = [search (True, i) for i in range (tr, 0, -1)]
fv = [search (False, i) for i in range (1, tr+1)]
vmulti = bv + fv
vmulti = core.std.Interleave (vmulti)
return vmulti
def degrainn (src, comp, pelclip, vmulti, tr=6, pel=4, thsad=400, thscd1=10000, thscd2=255):
core = vs.get_core ()
comp16 = core.fmtc.bitdepth (comp, fulls=True, fulld=True, bits=16, flt=False)
src16 = core.fmtc.bitdepth (src, fulls=True, fulld=True, bits=16, flt=False)
superclip = core.mv.Super (comp16, pel=pel, chroma=False, hpad=32, vpad=32, pelclip=pelclip, sharp=2, rfilter=2, levels=0)
def MDG1 (a):
bv = core.std.SelectEvery (vmulti, tr*2, tr-1-a)
fv = core.std.SelectEvery (vmulti, tr*2, tr+a)
MDG = core.mv.Degrain1 (src16, superclip, bv, fv, thsad=thsad, thscd1=thscd1, thscd2=thscd2, plane=0, limit=65535)
MDG = core.fmtc.bitdepth (MDG, fulls=True, fulld=True, bits=32, flt=True)
return MDG
MDGMulti = [MDG1 (i) for i in range (0, tr)]
MDGMulti = core.std.Interleave (MDGMulti)
def MDGMerge (start=None, a=2):
start = core.std.Merge (core.std.SelectEvery (MDGMulti, tr, 0), core.std.SelectEvery (MDGMulti, tr, 1), 0.5) if start is None else start
merge = core.std.Merge (start, core.std.SelectEvery (MDGMulti, tr, a), 1/(a+1))
a = a+1
clip = merge if a == tr else MDGMerge (start=merge, a=a)
return clip
return MDGMerge ()
def nrfinal (spatial, dif, peldif, vmulti, pel=4, tr=6, thsad=4800, thscd1=10000, thscd2=255):
core = vs.get_core ()
blankd = core.std.Expr ([dif], "0.5")
comp = degrainn (blankd, dif, peldif, vmulti, tr=tr, pel=pel, thsad=thsad, thscd1=thscd1, thscd2=thscd2)
NR = core.std.MergeDiff (spatial, comp)
return NR
def padding (src, left=0, right=0, top=0, bottom=0):
core = vs.get_core ()
w = src.width
h = src.height
clip = core.fmtc.resample (src, w+left+right, h+top+bottom, -left, -top, w+left+right, h+top+bottom, kernel="point", fulls=True, fulld=True)
return clip
spt = core.std.CropRel (core.knlm.KNLMeansCL(padding(clp,24,24,24,24), 0, 24, 4, h=3.2),24,24,24,24)
dif = core.std.MakeDiff(clp,spt)
vec = getvectors (spt, None)
clp = nrfinal (spt, dif, None, vec)
clp.set_output ()
jackoneill
3rd September 2015, 11:24
Can't you simply make Blender generate your images without that noise in them, or with less noise?
YAFU
3rd September 2015, 13:42
@feisty2, thanks. "vsedit" shows me the following error:
Failed to evaluate the script:
Python exception: matrix: output bitdepth not supported.
Traceback (most recent call last):
File "vapoursynth.pyx", line 1469, in vapoursynth.vpy_evaluateScript (src/cython/vapoursynth.c:23703)
File "/media/TEMPORAL/scrypt.vpy", line 5, in <module>
clp = core.fmtc.matrix (clp, mat="601", col_fam=vs.YUV, bits=32, fulls=True, fulld=True)
File "vapoursynth.pyx", line 1368, in vapoursynth.Function.__call__ (src/cython/vapoursynth.c:22272)
vapoursynth.Error: matrix: output bitdepth not supported.
And if I change that line 32 by 16, now I get the following error:
Failed to evaluate the script:
Python exception: knlm.KNLMeansCL: VapourSynthCreate error (clBuildProgram)!
Traceback (most recent call last):
File "vapoursynth.pyx", line 1469, in vapoursynth.vpy_evaluateScript (src/cython/vapoursynth.c:23703)
File "/media/TEMPORAL/scrypt.vpy", line 59, in <module>
spt = core.std.CropRel (core.knlm.KNLMeansCL(padding(clp,24,24,24,24), 0, 24, 4, h=3.2),24,24,24,24)
File "vapoursynth.pyx", line 1368, in vapoursynth.Function.__call__ (src/cython/vapoursynth.c:22272)
vapoursynth.Error: knlm.KNLMeansCL: VapourSynthCreate error (clBuildProgram)!
I'll try to find a simple script that makes use of "KNLMeansCL" to determine whether it is working properly on my installation.
@jackoneill. Yes, I could render with less noise increasing the render samples. But it means much greater render time by frame. You can spend hours/days rendering a few seconds of animation. That's why we are interested in reducing noise to save time with less samples. So, if by using images with more color depth I can avoid banding, that would be great.
MonoS
3rd September 2015, 13:59
@jackoneill. Yes, I could render with less noise increasing the render samples. But it means much greater render time by frame. You can spend hours/days rendering a few seconds of animation. That's why we are interested in reducing noise to save time with less samples. So, if by using images with more color depth I can avoid banding, that would be great.
As i expected, you are using a ray tracer, right??
If i remember right the "noise" you get it's not noise but lack of enough rays to build a proper pixel, so, if my understanding of the problem and the nature of the noise is right, you can substitute the first call to ft3dfilter with a gaussian blur [this will level out this lack of photons and make a better image for motion estimation], for the second call i don't know if it will be very useful, a lot of non static noise are already been removed by Degrain2
So, try removing the second call to ft3dfilter and substituting the first call with core.std.GBlur(ret, sigma=1.0) [IIRC GBlur don't work well with 16bit frames, you should try]
For png is to be expected some banding if you still use an 8bit pipeline, the use of png is needed to avoid jpeg compression artifact and chroma subsampling [you can turn off subsampling and use 100% quality, but you'll still get some little artifact and probably a bigger size than png].
Start saving your render in 16bit PNG then build up from this, now i'll take some look using your package.
EDIT: my apologies, the second call to ft3dfilter is required to remove quite a bit of remaining noise, i emulated it using dfttest but it cut out a lot of details as feisty2 said.
Also i made some errors in the script i sent you this morning, imwri read subsampled jpeg as RGB24 even if they in some sense are not, i'll post here the updated test script
input = core.fmtc.bitdepth(src, flt=True).fmtc.matrix(mat="601", col_fam=vs.YUV).fmtc.bitdepth(bits=16)
superF1 = core.generic.GBlur(input, 1.0)
superF2 = core.mv.Super(superF1, pel=2, sharp=1)
super = core.mv.Super(input)
#mvbw3 = core.mv.Analyse(superF2, isb=True, delta=3, overlap=4)
mvbw2 = core.mv.Analyse(superF2, isb=True, delta=2, overlap=4)
mvbw = core.mv.Analyse(superF2, isb=True, delta=1, overlap=4)
mvfw = core.mv.Analyse(superF2, isb=False, delta=1, overlap=4)
mvfw2 = core.mv.Analyse(superF2, isb=False, delta=2, overlap=4)
#mvfw3 = core.mv.Analyse(superF2, isb=False, delta=3, overlap=4)
ret = core.mv.Degrain2(clip=input, super=super, mvbw=mvbw, mvfw=mvfw, mvbw2=mvbw2, mvfw2=mvfw2, thsad=400)
ret = core.dfttest.DFTTest(ret, sigma=2.5).fmtc.bitdepth(bits=8, dmode=7)
ret.set_output()
this produced quite some nice [and washed out] result, here some screen
Frame 35: http://abload.de/img/nuovovapoursynthpytho77oeb.png
Frame 96: http://abload.de/img/nuovovapoursynthpytho4bqxt.png
last thing: there's already some banding in your original jpeg, you can't see it but if you apply some amplification you'll see it
frame 34: http://abload.de/img/nuovovapoursynthpythoqjodx.png
feisty2
3rd September 2015, 14:38
@YAFU
corrected
edit:.. just @ed the wrong guy... that's embarrassing
YAFU
3rd September 2015, 14:45
@MonoS, That's right, Cycles is a ray tracing renderer:
https://www.blender.org/manual/render/cycles/settings/light_paths.html
You can configure static noise pattern or random noise pattern. With static noise the noise reduction with the script does not work. The images I uploaded have random noise pattern.
I will analyze what you say and do some tests, it is a bit complicated to understand for me.
I'll upload a png sequence of 20 images at 16 bits for you can analyze if you want. But it will take some time because my bandwidth to upload is not good.
Thanks.
MonoS
3rd September 2015, 15:01
@MonoS, That's right, Cycles is a ray tracing renderer:
https://www.blender.org/manual/render/cycles/settings/light_paths.html
You can configure static noise pattern or random noise pattern. With static noise the noise reduction with the script does not work. The images I uploaded have random noise pattern.
I will analyze what you say and do some tests, it is a bit complicated to understand for me.
I'll upload a png sequence of 20 images at 16 bits for you can analyze if you want. But it will take some time because my bandwidth to upload is not good.
Thanks.
if you don't understand something don't be ashamed to ask, i've build up this knowledge across many years of experience across different subject [in which videogame and relative development are a crucial part :D].
The reason why with the static noise the script doesn't work is because the script try to distinguish between detail and noise using the movement of the camera and the object and applying denoising only on what is changed between frames [in the case of my example script, 2 previous, the current and 2 successive frames], with static noise, as the name says, the noise don't move so for the script the noise become detail.
Maybe someone more expert than me can come up with an intelligent idea on how to remove the static noise using the fact that it's static and so a mask can be created to modify only the affected pixels, who know
YAFU
3rd September 2015, 16:07
@MonoS, Thanks. Your tests look promising. I'll be doing some tests, perhaps this weekend.
Here I uploaded a sequence of png images at 16 bits. I have also included the blender scene in case any of you want to play with it :)
https://www.dropbox.com/s/xfndrsx5gwz7wkp/png%2016%20bit%20and%20scene.zip?dl=0
Download Blender (OpenSource, Free). Open the scene with Blender. The scene is set to use nvidia GPU (CUDA). If you do not have a good graphics card, in the right panel under "Render" in "Device" choose "CPU". Then on that panel a little below under "Performance" in "Tiles" you put a value of 32 in X and Y (32 is not related to bits, this is only frame size of each thread processor). To render the scene, in above menu in "Render" > "Render Animation". The images are saved by default in your "tmp" folder. Esc aborts rendering. If you want to play with the scene, the right mouse button selects objects. For navigate the 3D view (orbit) press the middle mouse button. You can play animation in the viewport (not rendered) by clicking the play button below in the timeline. What I say just if you want to spend a little fun time with Blender 3D :) . This scene is very simple just for testing and renders it relatively quickly.
Regarding noise reduction, I think random noise patterns is the right way to proceed, especially if the image has no quick/fast changes between frame and frame. Without knowing much about this, I think it would be relative easy to detect noise with static noise pattern, but then some algorithm should reconstruct the image below the noise considering neighbors pixels, and that would be quite difficult and maybe without good result.
@feisty2, do you know some very simple script where I can test whether "KNLMeansCL" is working well? I think OpenCL headres I installed to compile it only work with opensource drivers (I'm using "nvidia" driver), but I do not know.
feisty2
3rd September 2015, 16:16
##Load Vaporsynth
import vapoursynth as vs
core = vs.get_core()
##Load The Source Clip
clp = core.imwri.Read('png-50/%04d.png', firstnum=1, alpha=False)
clp = core.fmtc.bitdepth (clp, bits=32, fulls=True, fulld=True, flt=True)
clp = core.fmtc.matrix (clp, mat="601", fulls=True, fulld=True)
##The Actual KNLMeansCL
clp = core.knlm.KNLMeansCL(clp, d=0, a=24, s=4, h=3.2)
##Output
clp.set_output ()
YAFU
3rd September 2015, 16:40
Yes, I get the error
Failed to evaluate the script:
Python exception: knlm.KNLMeansCL: VapourSynthCreate error (clBuildProgram)!
Traceback (most recent call last):
File "vapoursynth.pyx", line 1469, in vapoursynth.vpy_evaluateScript (src/cython/vapoursynth.c:23703)
File "/media/TEMPORAL/scrypt.vpy", line 9, in <module>
clp = core.knlm.KNLMeansCL(clp, d=0, a=24, s=4, h=3.2)
File "vapoursynth.pyx", line 1368, in vapoursynth.Function.__call__ (src/cython/vapoursynth.c:22272)
vapoursynth.Error: knlm.KNLMeansCL: VapourSynthCreate error (clBuildProgram)!
I'll search what I need to compile correctly for nvidia in Linux.
MonoS
3rd September 2015, 17:34
I made some more test and consideration, and i noticed that after the first denoising stage the only noise left is on the low lights so i've modified the second denoising stage to use a mask
deno1 = core.mv.Degrain2(clip=input, super=super, mvbw=mvbw, mvfw=mvfw, mvbw2=mvbw2, mvfw2=mvfw2, thsad=400)
def f(x):
if x < 12000:
return 65535
else:
return 0
maskY = core.std.Lut(deno, [0], function=f).std.ShufflePlanes([0], vs.GRAY)
mask = core.std.ShufflePlanes([maskY, maskY, maskY], [0,0,0], vs.YUV)
deno2 = core.dfttest.DFTTest(deno, sigma=2.5)
ret = core.std.MaskedMerge(deno,deno2, mask)#.fmtc.bitdepth(bits=8, dmode=7)
ret.set_output()
#remove the # from the line below to see the mask
#maskY.set_output()
It still use dfttest because i don't want to install KNLMeansCL right now but would be enough to substitute the function call
feisty2
3rd September 2015, 17:43
Install? Sounds real complicated...
I didn't "install" knlmeanscl, just put the .dll in the plugin folder, then, it's just okay
Why u guys gotta "install" it?
YAFU
3rd September 2015, 18:03
@feisty2, dll is for windows. It is not easy to find binaries for Linux :(
Even developers usually share binaries for Windows, but only sources for Linux. But this is understandable, because each distro maintainers are responsible for putting the binaries in repositories. But for not very common applications is a bit more difficult to find them.
@MonoS, In mensje #237 in the first line I have replaced "src" by "clip=ret". Is it right?
EDIT:
otherwise I get the following error:
Failed to evaluate the script:
Python exception: name 'src' is not defined
Traceback (most recent call last):
File "vapoursynth.pyx", line 1469, in vapoursynth.vpy_evaluateScript (src/cython/vapoursynth.c:23703)
File "/media/TEMPORAL/scrypt.vpy", line 35, in <module>
input = core.fmtc.bitdepth(src, flt=True).fmtc.matrix(mat="601", col_fam=vs.YUV).fmtc.bitdepth(bits=16)
NameError: name 'src' is not defined
But maybe I'm doing something wrong because I'm building the script with parts of the lines you posted on each message.
I also needed this (in case some user read this thread in the future):
https://github.com/chikuzen/GenericFilters
https://github.com/HomeOfVapourSynthEvolution/VapourSynth-DFTTest
MonoS
3rd September 2015, 18:17
@feisty2: i hope this is enough of a reason to not "install" something XD http://abload.de/img/clipboard02wxobh.png [AKA i've other things to do]
@YAFU: I've made hack upon hack on the initial script you linked us, now mine look like this
src = core.imwri.Read("C:/Users/MonoS/Desktop/BlenderCycles-VapourSynth/images/%04d.png", firstnum=50)
input = core.fmtc.bitdepth(src, flt=True).fmtc.matrix(mat="601", col_fam=vs.YUV).fmtc.bitdepth(bits=16, dmode=7)
superF1 = DitherLumaRebuild(input, s0=1)
superF2 = core.mv.Super(superF1, pel=2, sharp=1)
super = core.mv.Super(input)
mvbw2 = core.mv.Analyse(superF2, isb=True, delta=2, overlap=4)
mvbw = core.mv.Analyse(superF2, isb=True, delta=1, overlap=4)
mvfw = core.mv.Analyse(superF2, isb=False, delta=1, overlap=4)
mvfw2 = core.mv.Analyse(superF2, isb=False, delta=2, overlap=4)
deno = core.mv.Degrain2(clip=input, super=super, mvbw=mvbw, mvfw=mvfw, mvbw2=mvbw2, mvfw2=mvfw2, thsad=400)
def f(x):
if x < 12000:
return 65535
else:
return 0
maskY = core.std.Lut(deno, [0,1,2], function=f).std.ShufflePlanes([0], vs.GRAY)
mask = core.std.ShufflePlanes([maskY, maskY, maskY], [0,0,0], vs.YUV)
ret = core.std.MaskedMerge(deno,core.dfttest.DFTTest(deno, sigma=2.5), mask)#.fmtc.bitdepth(bits=8, dmode=7)
now i don't know if in your script input and ret are the same clip
you don't need anymore GBlur, some testing showed me that it lower the final quality and destroy a lot of small details, so no need to use generics [and AFAIK they'll be included in the next main version of vapour]
If feisy said that dfttest is not the ideal solution, trust him, he surely made more extensive testing than me on that, so better link KNLMeansCL
Are_
3rd September 2015, 19:58
@YAFU: on gentoo you need to install nvidia-drivers and it's uvm kernel module, I don't know if it is included in your distro of if it is your problem at all.
YAFU
3rd September 2015, 22:11
hi Are_
Using Kubuntu 64 bits.
"nvidia_uvm" seems loaded into the kernel and nVidia OpenCL in Blender 3D seems to be working properly.
I asked in the KNLMeans thread to see if they can help me.
feisty2
4th September 2015, 08:30
@jackoneill
BlockFPS crashes mvtools on GRAY clips (I think something is wrong inside "mvblockfpsFree")
EDIT:
fixed, pulled a request on Git
mawen1250
5th September 2015, 13:10
For eliminating static noise, you might want to give BM3D (http://forum.doom9.org/showthread.php?t=172172) a try, which can do an excellent job for nearly all kinds of small noise patterns.
feisty2
5th September 2015, 15:17
xxx
sup = MSuper(last,chroma=False)
bv1 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1,chroma=False)
fv1 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1,chroma=False)
bv2 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1,chroma=False)
fv2 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1,chroma=False)
bv3 = MAnalyse(sup,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1,chroma=False)
fv3 = MAnalyse(sup,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1,chroma=False)
MDegrain3(last, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=2000, thscd1=10000)
converttoy8 ()
http://i.imgur.com/10iTirI.png
import vapoursynth as vs
core = vs.get_core()
clp = xxx
clp = core.std.ShufflePlanes(clp, planes=0, colorfamily=vs.GRAY)
clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=32, flt=True)
clp2 = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=16)
sup = core.mvsf.Super(clp)
bv1 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1)
fv1 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1)
bv2 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1)
fv2 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1)
bv3 = core.mvsf.Analyze(sup,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1)
fv3 = core.mvsf.Analyze(sup,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1)
clp = core.mvsf.Degrain3(clp, sup, bv1, fv1, bv2, fv2, bv3, fv3, thsad=2000, thscd1=10000)
sup2 = core.mv.Super(clp2)
bv12 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1)
fv12 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=1,search=3,truemotion=True,dct=1)
bv22 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1)
fv22 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=2,search=3,truemotion=True,dct=1)
bv32 = core.mv.Analyse(sup2,isb=True,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1)
fv32 = core.mv.Analyse(sup2,isb=False,blksize=16,overlap=8,delta=3,search=3,truemotion=True,dct=1)
clp2 = core.mv.Degrain3(clp2, sup2, bv12, fv12, bv22, fv22, bv32, fv32, thsad=2000, thscd1=10000)
clp2 = core.fmtc.bitdepth(clp2, fulls=True, fulld=True, bits=32, flt=True)
fnl = core.std.StackHorizontal([clp,clp2])
fnl.set_output ()
http://i.imgur.com/19xhwJh.png
@jackoneill
guess I just fixed dct 1-4 (fftw modes) in my floating point branch
tried to fix it on uint16_t, your original version, but failed
maybe you could try to fix it yourself
more details at https://github.com/IFeelBloated/MVTools_SF/blob/master/DCTFFTW.cpp
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.