View Full Version : KNLMeansCL: OpenCL NLMeans de-noising algorithm [2018-01-29]
Groucho2004
2nd August 2019, 19:20
A Qwant search, plus following some links that seemed promising, revealed that version 3.0 of the AMD implementation can be found here:
http://amd-dev.wpengine.netdna-cdn.com/app-sdk/installers/APPSDKInstaller/3.0.130.135-GA/full/AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x86.exe
http://amd-dev.wpengine.netdna-cdn.com/app-sdk/installers/APPSDKInstaller/3.0.130.135-GA/full/AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.exe
If I'm using the 32-bit version of AVIsynth on a 64-bit OS, do I install the x86 version or the x64 version?
EDIT: "The operating system is not adequate for running AMD APP SDK 3.0". Son of a bitch.
There are old versions that run on XP. However, these are software emulations, they won't use your graphics hardware. You can just use TNLMeans which would be faster. See also this post (https://forum.doom9.org/showthread.php?p=1739321#post1739321).
It's usually best to use the OpenCL implementation that comes with your driver.
By the way, which graphics card are you using?
StainlessS
2nd August 2019, 20:05
Sorry bout OS not being OK, but thanks for the links.
I shall down them and bank until I find the enthusiasm to attempt re-try. cheers.
[Hopefully W7x64 is OK].
Katie Boundary
2nd August 2019, 21:14
You can just use TNLMeans which would be faster. See also this post (https://forum.doom9.org/showthread.php?p=1739321#post1739321).
Is TNLMeans included in KNLmeans or do I have to download it separately? Where's the documentation for this plugin, anyway?
By the way, which graphics card are you using?
I've been using AMD integrated graphics (A10-7860K, Radeon R7) ever since my Geforce 730 died a few months ago.
Sorry bout OS not being OK, but thanks for the links.
I shall down them and bank until I find the enthusiasm to attempt re-try. cheers.
[Hopefully W7x64 is OK].
I'm happy I could help :) Win7 should be fine; it's still being supported by Microsoft until the beginning of next year so everyone else in the industry kind of has to support it too.
ChaosKing
2nd August 2019, 21:19
It is a separate plugin http://avisynth.nl/index.php/TNLMeans
Groucho2004
2nd August 2019, 21:51
I've been using AMD integrated graphics (A10-7860K, Radeon R7)Maybe you find answers here (https://www.geeks3d.com/20181220/how-to-enable-intel-opencl-support-on-windows-when-amd-radeon-graphics-driver-is-installed/) on enabling OpenCL support. Please note that the latest KNLMeansCL requires OpenCL 1.2. If your card only supports OpenCL 1.1, you'll have to go back to a previous version, see here (https://github.com/Khanattila/KNLMeansCL/wiki/Requirements).
Katie Boundary
2nd August 2019, 21:51
All right, excellent. I now have fully functional non-local means denoising in XP. Thanks everyone!
Maybe you find answers here (https://www.geeks3d.com/20181220/how-to-enable-intel-opencl-support-on-windows-when-amd-radeon-graphics-driver-is-installed/) on enabling OpenCL support.
"On a Windows 10 system with..."
Well then that's a big no. It'll be a cold day in hell before I use Win10 for anything or even go back to Win8.1
Groucho2004
2nd August 2019, 21:57
All right, excellent. I now have fully functional non-linear means denoising in XP. Thanks everyone!I believe you mean non-local means. ;)
Katie Boundary
3rd August 2019, 06:03
Fixed lol
aymanalz
14th October 2019, 04:11
Any tips on what settings to use if I want KNLMeansCL purely for degraining? That is, I want it to remove a lot of grain, but (hopefully) no other detail? Live action film, not anime.
Cary Knoop
14th October 2019, 04:32
Any tips on what settings to use if I want KNLMeansCL purely for degraining? That is, I want it to remove a lot of grain, but (hopefully) no other detail? Live action film, not anime.
I recommend testing it, there is no one cookie-cutter setting.
For instance, use a combination of stack horizontal and vertical to create a video matrix with various settings, pick the one that is most to your liking.
Or interleave various settings and go through them one by one.
Alternatively, you might want to opt for BM3D for removing grain. It's slow though, until someone ports a GPU version (hint, hint, wink, wink).
aymanalz
14th October 2019, 05:13
I recommend testing it, there is no one cookie-cutter setting.
For instance, use a combination of stack horizontal and vertical to create a video matrix with various settings, pick the one that is most to your liking.
Or interleave various settings and go through them one by one.
Alternatively, you might want to opt for BM3D for removing grain. It's slow though, until someone ports a GPU version (hint, hint, wink, wink).
Someone has ported BM3D to GPU, but it is in prototype stage as of now. (So says the Vapoursynth wiki.)
I'd prefer to use the GPU for degraining, as my encoding is already very slow. That's why I'm trying KNLmeansCL.
In general, for removing grain, does increasing the temporal parameter (d) help? How high can I increase the h parameter, without starting to lose other details?
Are there any grain removal specific combinations of the settings?
Also, which weighting function should I use?
Cary Knoop
14th October 2019, 18:40
Are there any grain removal specific combinations of the settings?
Also, which weighting function should I use?
Testing is the answer to your questions!
There are no magic settings.
videoh
14th October 2019, 19:33
There's no formal definition of "grain", so we can't be sure what you mean by degraining. For me, grain is a film thing and it doesn't cross frames, so temporal processing is not needed. Tell us more or better still give us a sample.
Cary Knoop
14th October 2019, 19:40
For me, grain is a film thing and it doesn't cross frames, so temporal processing is not needed.
How on Earth did you make the conclusion that temporal processing is not needed?
What you say is completely wrong!
videoh
14th October 2019, 20:09
Cary is throwing a narc tantrum because someone has a different opinion.
Atak_Snajpera
14th October 2019, 20:56
There's no formal definition of "grain", so we can't be sure what you mean by degraining. For me, grain is a film thing and it doesn't cross frames, so temporal processing is not needed. Tell us more or better still give us a sample.
You obviously have never used temporal mdegrain1/2/3 filter If you think that temporal processing is basically useless.
videoh
14th October 2019, 21:15
I never said "temporal processing is basically useless", which means you are a scoundrel. DG is still living rent-free in your head. Loving it!
Atak_Snajpera
14th October 2019, 21:29
I never said "temporal processing is basically useless", which means you are a scoundrel. DG is still living rent-free in your head. Loving it!
Temporal mdegrain will always give you better quality than knlmeanscl or any other spatial filter. Deal with IT. Spatial denoising like knlmeanscl destroys details like crazy. After all those years You are still such a noob...
LigH
15th October 2019, 07:15
No religious wars, please. Thank you.
Cary Knoop
22nd October 2019, 20:12
Question about KNLMeansCL: Would it be beneficial to detect pre-deinterlace noise patterns with this filter or should this filter only be used after proper deinterlacing?
poisondeathray
22nd October 2019, 21:39
Question about KNLMeansCL: Would it be beneficial to detect pre-deinterlace noise patterns with this filter or should this filter only be used after proper deinterlacing?
progressive only, otherwise it will mess up the fields
either a) double rate deinterlace; or b) separate grouped even /odd fields and apply to each separately then weave back . For (b) you retain original fields, but you don't get temporal denoising between even/odd fields . I would say (a) is preferred
Cary Knoop
22nd October 2019, 21:57
progressive only, otherwise it will mess up the fields
either a) double rate deinterlace; or b) separate grouped even /odd fields and apply to each separately then weave back . For (b) you retain original fields, but you don't get temporal denoising between even/odd fields . I would say (a) is preferred
When I wrote interlaced I actually meant to use option b.
I was thinking about doing a first run using option b and then deinterlace (with frame doubling) and apply a second run.
But the question is if that is worth it?
poisondeathray
22nd October 2019, 22:09
When I wrote interlaced I actually meant to use option b.
I was thinking about doing a first run using option b and then deinterlace (with frame doubling) and apply a second run.
But the question is if that is worth it?
You can try it; but I don't think it's worth it in general (for other denoisers as well, not just KNLMeansCL) . When you process even/odd separately , you can introduce a type of flicker because you don't even out the pattern between even/odd
If there was some type of defect limited to , say the even fields, then you might do that as to not contaminate the other odd fields with temporal processing (denoising or double rate deinterlacing with temporal smoothing like QTGMC). Or if one group had more noise (e.g. maybe chroma noise) than the other , you might preprocess them separately with different strengths and filters applied to even vs. odd
aymanalz
26th October 2019, 12:47
KNLmeansCL seems to have no effect on the output file when the weighing function chosen is anything other than Welsch. Has anybody else experienced this? During the encode, the GPU runs at high power, but the output file remains un-denoised, if I select any other weighing function.
I mentioned this to @selur, as I thought it's a bug in his program "Hybrid", and he was able to confirm the bug - but he stated that the bug is in KNLmeansCL.
Selur
26th October 2019, 13:21
Hybrid properly uses:
clip = core.knlm.KNLMeansCL(clip=clip)
clip = core.knlm.KNLMeansCL(clip=clip, wmode=1)
clip = core.knlm.KNLMeansCL(clip=clip, wmode=2)
clip = core.knlm.KNLMeansCL(clip=clip, wmode=3)
no error occurs, but interleaving the filtered and unprocessed frames does not show a differenc if wmode != 0.
(Hybrid uses KNLMeansCL 1.1.1)
Cu Selur
Cary Knoop
26th October 2019, 16:36
KNLmeansCL seems to have no effect on the output file when the weighing function chosen is anything other than Welsch. Has anybody else experienced this?
I have no problem with for instance Modified Bisquare on Vapoursynth.
aymanalz
26th October 2019, 17:11
I have no problem with for instance Modified Bisquare on Vapoursynth.
What program do you use? Hybrid or Staxrip or...
Additionally, and I'm not sure if this is important, but what are you encoding from and to? x264/x265/something else?
Cary Knoop
26th October 2019, 18:30
What program do you use? Hybrid or Staxrip or...
Additionally, and I'm not sure if this is important, but what are you encoding from and to? x264/x265/something else?
Just straight Vapoursynth piped to FFmpeg.
No, the codec is not relevant. When I do a diff using Vapoursynth Editor, I can see a clear difference.
Selur
27th October 2019, 06:14
You are right there are differences using:
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/KNLMeansCL/KNLMeansCL.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2k.dll")
# Loading source using FFMS2K
clip = core.ffms2.Source(source="F:/TESTCL~1/files/test.avi",cachefile="E:/Temp/avi_078c37f69bb356e7b5fa040c71584c40_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
original = clip
# denoising using KNLMeansCL
clip = core.knlm.KNLMeansCL(clip=clip, wmode=2)
# adjusting for FilterView
if original.format.id != clip.format.id:
if (original.format.color_family == vs.RGB and clip.format.color_family != vs.RGB):
original = core.resize.Bicubic(original, format=clip.format.id, matrix_s="470bg", range_s="limited")
elif (original.format.color_family == clip.format.color_family):
original = core.resize.Bicubic(original, format=clip.format.id, range_s="limited")
else:
original = core.resize.Bicubic(original, format=clip.format.id, matrix_in_s="470bg", range_s="limited")
diff = core.std.MakeDiff(clip, original)
# Output
diff.set_output()
I can see differences even when not using wmode=9, but they are way less then when using wmode=0.
Instead of
diff = core.std.MakeDiff(clip, original)
# Output
diff.set_output()
Hybrid uses something like:
original = core.text.Text(original,"Original")
clip = core.text.Text(clip,"Filtered")
interleaved = core.std.Interleave([original, clip])
# Output
interleaved.set_output()
-> Looks to me like neither a bug in Hybrid or the filter, but simply that with wmode=2 those subtle differences are really hard to spot when looking at the frames itself. :)
Cu Selur
Cary Knoop
27th October 2019, 07:00
Out of curiosity why all the testing of the color format? KNLMeans does not convert the format. Also for YUV by default color is not processed.
Selur
27th October 2019, 07:24
Like the script states '# adjusting for FilterView' Hybrid does adjust the color (just) for the preview (converting to RGB in the script instead of having the editor used for the preview do it). :)
The color part before that:
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
is only used to make sure Vapoursynth assumes the same color matrix etc. that Hybrid assumes from the analysis of the source.
Cu Selur
aymanalz
27th October 2019, 10:46
-> Looks to me like neither a bug in Hybrid or the filter, but simply that with wmode=2 those subtle differences are really hard to spot when looking at the frames itself. :)
Cu Selur
In one of the earlier pages on this thread, @khanattila suggested using wmode=2 for removing heavy grain. But if I do that, no matter how high the strength, no grain seems to get removed. If the differences are too subtle to notice, he wouldn't have suggested wmode=2 for heavy degraining, right?
Cary Knoop
27th October 2019, 16:24
In one of the earlier pages on this thread, @khanattila suggested using wmode=2 for removing heavy grain. But if I do that, no matter how high the strength, no grain seems to get removed. If the differences are too subtle to notice, he wouldn't have suggested wmode=2 for heavy degraining, right?
What parameters do you use?
Selur
29th February 2020, 08:35
Hi,
I'm getting:
KNLMeansCL(device_type="auto")
Avisynth preview error: Avisynth error : KNLMeansCL: fatal error! (oclUtilsGetPlaformDeviceIDs: OCL_UTILS_UNKNOWN_ERROR) (E:\Temp\tempPreviewAvisynthFile08_26_19_695.avs, line 11) Couldn't import -1 (1):
NLMeansCL2()
Avisynth preview error: Avisynth error �Dw.>: NLMeansCL2: Houston, we've had a problem! [clGetPlatformIDs (GENERIC_ERROR)] (E:\Temp\tempPreviewAvisynthFile08_26_28_182.avs, line 11) Couldn't import -1 (1): ?Dw.>
using Windows 10pro 1909 (Build 18363.657) with an AMD Ryzen 7 1800X and a Geforce GTX 1070 Ti driver version 442.50.
anyone else experiencing this?
Cu Selur
Ps.: ' core.knlm.KNLMeansCL(clip=clip)' in Vapoursynth works fine.
Sharc
29th February 2020, 10:11
No problem here.
Hybrid 2020.02.16.1
Windows 10 Home (x64) Build 18363.657 (1909)
Intel Core i5-8400
NVIDIA GeForce GTX 1050 Ti, 26.21.14.3630 (GeForce 436.30)
Installed Avisynth versions:
VersionString: AviSynth+ 3.4 (r2923, 3.4, i386)
VersionNumber: 2.60
File / Product version: 3.4.0.0 / 3.4.0.0
Interface Version: 6
Multi-threading support: Yes
VersionString: AviSynth+ 3.4 (r2923, 3.4, x86_64)
VersionNumber: 2.60
File / Product version: 3.4.0.0 / 3.4.0.0
Interface Version: 6
Multi-threading support: Yes
Selur
29th February 2020, 10:34
Okay, then it probably is a driver issue. -> Will do some testing.
Thanks for the feedback. :)
Cu Selur
Khanattila
29th February 2020, 11:46
It could be a driver problem indeed ... what version of AviSynth do you use?
Selur
29th February 2020, 12:23
tested different driver versions (from https://www.nvidia.com/Download/Find.aspx?lang=en-us used GeForce Game Ready Driver')
442.50 -> fail
442.19 -> fail
441.87 -> fail
441.66 -> fail
441.41 -> fail
441.20 -> fail
441.12 -> fail
441.08 -> failed to install: "Your system requires DCH driver packages,... " :/
440.97 -> failed to install: "Your system requires DCH driver packages,... " :/
436.48 -> failed to install: "Your system requires DCH driver packages,... " :/
436.30 -> failed to install: "Your system requires DCH driver packages,... " :/
deinstalled drivers using DDU, installed older drivers restarted, tested,...
I use AviSynth+ 0.1 (r272, MT, i386) according to version().
Cu Selur
StainlessS
29th February 2020, 12:30
Selur, r272 from 2014, dump and and get v3.4(Oct 2019):- https://github.com/AviSynth/AviSynthPlus/releases
EDIT: Nice speedup amongst other things.
Selur
29th February 2020, 12:57
I get the exactly same error message with "Avisynth+ 3.4 (r295, master, i386)",...
Groucho2004
29th February 2020, 14:12
I get the exactly same error message with "Avisynth+ 3.4 (r295, master, i386)",...????? How do you get these revision numbers / version strings?
Selur
29th February 2020, 14:31
Sorry, it's 'r2925', lost the 2 during typing.
https://i.ibb.co/s5mbNVM/avisynth-Plus.png
I get it my calling 'version()' and look at it in AvsPmod,...
Groucho2004
29th February 2020, 14:35
Sorry, it's 'r2925', lost the 2 during typingAh, OK.
tormento
1st March 2020, 13:52
436.30 -> failed to install: "Your system requires DCH driver packages,... " :/
deinstalled drivers using DDU, installed older drivers restarted, tested,..
Unfortunately DCH will be a mandatory step. Anyway here with 450.12 everything is working fine and bit faster too.
Selur
5th March 2020, 20:20
Anyway here with 450.12 everything is working fine and bit faster too.
Where did you get that version?
'442.50' is the latest I see over at NVIDIAs Download site (https://www.nvidia.de/Download/Find.aspx?lang=en)
Cu Selur
tormento
6th March 2020, 11:31
Where did you get that version?
Included in Windows Insider version.
It gives you WDDM 2.7:
Hardware-accelerated GPU scheduling (An additional option in the system settings, which increases the minimum and average fps to reduce latency)
Shader Model 6.5
DirectX 12 Raytracing Tier 1.1
DirectX 12 Mesh Shader
DirectX 12 Sampler Feedback: Texture Streaming, Texture-Space Shading
DirectX 12 Video Protected Resource Support
Selur
6th March 2020, 14:25
Ah okay, then I'll wait for it to be available. Will stick with Vapoursynth for the time being, but good to know it'll be fixed in a newer version.
Cu Selur
tormento
8th March 2020, 09:45
good to know it'll be fixed in a newer version
Newer versions=mandatory DCH
Selur
19th March 2020, 19:51
hmm,..
Geforce Experience just installed 442.74, sadly those drivers didn't help.:/
(luckily hardware filters seem to work fine with Vapoursynth)
Cu Selur
tormento
19th March 2020, 21:05
hmm,..
Geforce Experience just installed 442.74, sadly those drivers didn't help.:/
(luckily hardware filters seem to work fine with Vapoursynth)
Cu Selur
Why oh why you uninstalled DCH?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.