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 > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd September 2015, 16:40   #241  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
Yes, I get the error
Code:
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.
YAFU is offline   Reply With Quote
Old 3rd September 2015, 17:34   #242  |  Link
MonoS
Registered User
 
Join Date: Aug 2012
Posts: 203
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

Code:
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
MonoS is offline   Reply With Quote
Old 3rd September 2015, 17:43   #243  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
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?
feisty2 is offline   Reply With Quote
Old 3rd September 2015, 18:03   #244  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
@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:
Code:
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/HomeOfVapourSynth...rSynth-DFTTest

Last edited by YAFU; 3rd September 2015 at 18:13.
YAFU is offline   Reply With Quote
Old 3rd September 2015, 18:17   #245  |  Link
MonoS
Registered User
 
Join Date: Aug 2012
Posts: 203
@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
Code:
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
MonoS is offline   Reply With Quote
Old 3rd September 2015, 19:58   #246  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 321
@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.
Are_ is offline   Reply With Quote
Old 3rd September 2015, 22:11   #247  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
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.
YAFU is offline   Reply With Quote
Old 4th September 2015, 08:30   #248  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
@jackoneill
BlockFPS crashes mvtools on GRAY clips (I think something is wrong inside "mvblockfpsFree")

EDIT:
fixed, pulled a request on Git

Last edited by feisty2; 4th September 2015 at 10:08.
feisty2 is offline   Reply With Quote
Old 5th September 2015, 13:10   #249  |  Link
mawen1250
Registered User
 
Join Date: Aug 2011
Posts: 103
For eliminating static noise, you might want to give BM3D a try, which can do an excellent job for nearly all kinds of small noise patterns.
mawen1250 is offline   Reply With Quote
Old 5th September 2015, 15:17   #250  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Code:
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 ()


Code:
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 ()


@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/MVTo...er/DCTFFTW.cpp
feisty2 is offline   Reply With Quote
Old 7th September 2015, 13:30   #251  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
Hello. I've been doing some experiments.
Apparently what mainly produces banding is this line at end in the original script:
Code:
ret = core.fft3dfilter.FFT3DFilter(ret,sigma=2.5, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.7)
http://www.pasteall.org/60466

I have understood that this line is to reduce fine grain noise, right?
I found a good way for those banding are not very noticeable. Basically, create a lossless video with the original script, but without that line.

Then apply the script to the resulting video, but in superF1 replacing with the values of that line that was removed:
Code:
import vapoursynth as vs
core = vs.get_core()

##
##ffmpeg with ffms2
core.std.LoadPlugin('/usr/lib/x86_64-linux-gnu/libffms2.so.3')
ret = core.ffms2.Source(source='/PATH_TO_VIDEO_HERE/encoded.mkv')
##
input = core.fmtc.bitdepth (clip=ret, bits=8)
 
superF1 = core.fft3dfilter.FFT3DFilter(input,sigma=2.5, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.7)
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.Degrain3(clip=input, super=super, mvbw=mvbw, mvfw=mvfw, mvbw2=mvbw2, mvfw2=mvfw2, mvbw3=mvbw3, mvfw3=mvfw3, thsad=400)
 
ret.set_output()
Then the noise reduction is similar to original script, but with less banding.
I guess that I've done it can be done from a single script without the intermediate step by creating these first video, but I have no idea about how to create this script. How could I do it?

The noise reduction in the kind of noise that renders from Blender 3D generate using this method/script is amazing.
It is a pity that Fft3d not support 16 bits because the result could be even better. Do you know if that filter is still under development and whether it plans to support 16-bit?

Last edited by YAFU; 7th September 2015 at 13:38.
YAFU is offline   Reply With Quote
Old 7th September 2015, 16:41   #252  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
Hello HolyWu.
It seems that in the HAvsFunc thread there are no instructions for Linux. Where should I copy havsfunc.py in Linux?
Regarding suggestions of MonoS, I was able to build this script with parts of code from his different messages, I do not know if I have done well:
http://www.pasteall.org/61017
For now I get better noise reduction with the original script using FFT3DFilter.
YAFU is offline   Reply With Quote
Old 7th September 2015, 19:24   #253  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
Just in case this is useful to someone else, I explain:

I have installed at least three versions of python (I guess they have been left of different system updates). So I have different paths to "/pythonX.Y/site-packages" both in "/usr/local/lib" and "/usr/lib". So from linux terminal:
Code:
whereis vapoursynth
And you get "/usr/local/lib/vapoursynth" or "/usr/lib/vapoursynth" depending on where you've installed it. Generally if you have compiled without specified path, default it is installed in "/usr/local/lib/", and if you installed from a distribution package generally is installed in "/usr/lib". So depending on that copy "havsfunc.py" to "/usr/local/lib/pythonX.Y/site-packages" or "/usr/lib/pythonX.Y/site-packages". "X.Y" should be the highest version of python you had when you installed vapoursynth. In my case I have copied it to "/usr/local/lib/python3.4/site-packages". In the same path there were two files, "vapoursynth.la" and "vapoursynth.so".

I will study this little script and do some testing with these images that I have shared in previous posts in this thread.
YAFU is offline   Reply With Quote
Old 7th September 2015, 20:00   #254  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 321
If you don't want to deal with root access every time you want to update/install a new module:
Code:
# echo "/home/your-user/some-path-to-a-directory-with-all-your-modules" > /usr/local/lib/python3.4/site-packages/vapoursynth_modules.pth
Are_ is offline   Reply With Quote
Old 7th September 2015, 23:37   #255  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
Ok Are_, I'll try that
YAFU is offline   Reply With Quote
Old 8th September 2015, 19:03   #256  |  Link
MonoS
Registered User
 
Join Date: Aug 2012
Posts: 203
If someone don't come up with some suggestion, this is my "final suggestion"
The video outputted is this one http://www.mediafire.com/watch/mws7c9hgwwrsqjm/test.mkv
The script used this [i wrote some comments for you]

Code:
import vapoursynth as vs
import havsfunc as has

core = vs.get_core()

#Load imwri
core.std.LoadPlugin("C:/Program Files (x86)/VapourSynth/plugins64/imwri/imwri.dll")

#Read images
src = core.imwri.Read("C:/Users/MonoS/Desktop/BlenderCycles-VapourSynth/images/%04d.png", firstnum=50)

#converting input RGB images to YUV444
input = core.fmtc.bitdepth(src, flt=True).fmtc.matrix(mat="601", col_fam=vs.YUV).fmtc.bitdepth(bits=16, dmode=7)

#This should improve motion estimation for darken zones
superF1 = has.DitherLumaRebuild(input, s0=1)
superF2 = core.mv.Super(superF1, pel=2, sharp=1)

super = core.mv.Super(input)

#Do motion compesated denoising
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)

#After first denoising stage the majority of the grain is on the darker zone, create a mask of only the dark zones
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)

#Do a second pass of spatial denoising only on the masked zones
ret = core.std.MaskedMerge(deno,core.dfttest.DFTTest(deno, sigma=2.5), mask)

#Delete # below to output a 8bit clip
#ret = core.fmtc.bitdepth(bits=8, dmode=7)

ret.set_output()

#Delete # below to output a video showing the difference between the the first and second denoise pass
#core.std.Interleave([deno, ret]).set_output()

#Delete # below to output the mask
#mask.set_output()
I also suggest a moderator to move all this discussion about removing ray tracing noise artifact into a new thread, we went a bit to OT imho


EDIT: i've thrown inside the script the jpg you sent us at the beginning, FAAAAR better result if you ask me
http://www.mediafire.com/watch/ypwrf...fy/testjpg.mkv

Last edited by MonoS; 8th September 2015 at 19:24.
MonoS is offline   Reply With Quote
Old 8th September 2015, 21:01   #257  |  Link
YAFU
Registered User
 
Join Date: Aug 2015
Posts: 40
@MonoS, Thank you very much for your scripts and suggestions. I had not tasted much your scripts because I did not know how to create a functional script from what you said in each message, I really know very little about these issues and I am learning. With time I'm going to analyze what each filter do and learning how it works.
Edit: The comments you made into the last script are really helpful to learn, thanks.

In the BlenderArtists forum, "brothermechanic" has done new tests and he found a way to minimize banding:
http://www.blenderartists.org/forum/...=1#post2933482

For now we are stuck with "fft3dfilter", it seems to be the best handling this kind of noise generated by Blender/Cycles. But I will continue testing to find the best 16 bits solution.
You see the example with "hard-denoise" filter. Similar that way should look material in cubes if they have no noise in render. However, in other situations it would be necessary to preserve details, without much noise reduction.
Thanks.

Last edited by YAFU; 8th September 2015 at 21:50.
YAFU is offline   Reply With Quote
Old 14th September 2015, 04:04   #258  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Is there any possibility to get the functionality of MShow included? I use it quite often to adjust thscd1 and thscd2 to match the source better.

EDIT: Also, is it OK to simply resize to double the dimensions of the clip fed to Super as pelclip? In Avisynth 2.6, you need to do some shifting.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...

Last edited by Boulder; 14th September 2015 at 18:13.
Boulder is offline   Reply With Quote
Old 15th September 2015, 16:54   #259  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
OK, I got some more odd behaviour. It could be MVTools acting up but it's still quite interesting.

This one works properly, that is, Degrain1 does what it is supposed to do:
Code:
import vapoursynth as vs
import havsfunc as has

core = vs.get_core()

core.avs.LoadPlugin(r'c:/program files (x86)/avisynth/plugins/dgdecodenv.dll')
clp = core.avs.DGSource('c:/x265/hotfuzztest.dgi')

#clp = core.fmtc.bitdepth(clp, bits=16)

feed = has.DitherLumaRebuild(clp)

pelmdg = core.resize.Spline(clp,width=clp.width*2,height=clp.height*2)
pelprefilt = core.resize.Spline(feed,width=clp.width*2,height=clp.height*2)
  
superanalyse = core.mv.Super(feed,pel=2,chroma=True,rfilter=4, pelclip=pelprefilt)
supermdg = core.mv.Super(clp,pel=2,chroma=True,rfilter=4,levels=1, pelclip=pelmdg)

bv1 = core.mv.Analyse(superanalyse, dct=5, blksize=16, overlap=8, isb=True)
fv1 = core.mv.Analyse(superanalyse, dct=5, blksize=16, overlap=8)

finalclip = core.mv.Degrain1(clp, supermdg, bv1, fv1, thsad=400, thsadc=400, limit=5, limitc=6)

org = clp

final = core.std.Interleave(clips=[org,finalclip])

final.set_output()
If you uncomment the line "clp = core.fmtc.bitdepth(clp, bits=16)", Degrain1 doesn't seem to do anything.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 15th September 2015, 17:08   #260  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
all 10 modes of dct are broken in the current binary, dct 5-10 have been fixed in the source code, but no binary available yet, dct 1-4 are just broken
I fixed all dct stuff in my floating point branch tho, if u wanna try it

Last edited by feisty2; 15th September 2015 at 17:19.
feisty2 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 15:32.


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