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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th June 2020, 11:11   #1  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
CCD - Camcorder Color Denoise (Chroma spatial denoiser) - AVISynth+ version

CCD - Camcorder Color Denoise (Chroma spatial denoiser) - AVISynth+ version

Hello to all.

@Guest
@tritical
@pinterf
and other respected filter makers

Who can and knows exactly how:
Please make a version for AVISynth+ (x64 + MT) of VirtualDub filter "CCD - Camcorder Color Denoise" by Sergey Stolyarevsky.

http://acobw.narod.ru > Camcorder color denoise
http://acobw.narod.ru/file/ccd.zip

Sources here:
https://forum.doom9.org/showthread.p...25#post1916925

This filter "CCD" works much more correctly, and really suppresses chroma noise within the frame, without creating graphic artifacts, unlike the filter "Cnr2".

It would be very useful to have it in the form of a filter for AVISynth+ so that we can work using x64 + MT and directly in the YV12 color space without the need for double conversion YV12> RGB32> YV12.

Screenshots of some frames before and after processing by the filter "CCD - Camcorder Color Denoise" I attached.
CCD-Screenshots.zip (3.1 МБ) - PNG
https://mega.nz/file/ag5GFC4J#LWgqMq...LG3k5OaQ0BDOJI

Last edited by zybex; 27th June 2020 at 19:11.
zybex is offline   Reply With Quote
Old 14th June 2020, 12:18   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
In all probability, the filter you mention relies on RGB to do its thing, YUV conversion would likely not work as well or at all.
User Guest, has now undergone his latest transmogrification into videoh, and I suspect that he is currently on a 30 day 'vacation'.
Tritical, long time missing.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 14th June 2020, 12:43   #3  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
i believe nothing is impossible
zybex is offline   Reply With Quote
Old 14th June 2020, 13:12   #4  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
Quote:
Originally Posted by zybex View Post
i believe nothing is impossible
I would not be so sure... Try slamming the revolving door
Atak_Snajpera is offline   Reply With Quote
Old 14th June 2020, 14:34   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by Atak_Snajpera View Post
Try slamming the revolving door
Maybe not impossible, maybe just improbable.

Zybex,
Asking for anybody to emulate CCD without some source code is also improbable outcome [unless you know specifically and can point to method used]

This has problem in x64 but works in x86

Code:
# 64 bit VDF fails with error 0xC1, but filter works OK in VDUB2 x64, possible AVS+ VDubFilter.dll problem.

# VDub GUI "Show Noise" and "Disable" args not available external to VDUB, ie not usable in Avisynth.
# VDF accepts only RGB32
Function VD_CCD(clip clip, int "threshold", bool "multithreading",bool "ShowNoise",Int "preroll") {
    threshold      = Default(threshold,30)                                      # Default 30 as in Vdub
    multithreading = Default(multithreading,true)                               # Default true
    ShowNoise      = Default(ShowNoise,False)                                   # Simulated
    preroll        = Default(preroll,1)                                         # We've given default of 1 frames pre-rolled, maybe only 0 needed.
    Assert(clip.IsRGB32,"VD_CCD: Need RGB32")
    LoadVirtualdubPlugin("D:\VDUB\ccd_32bit.vdf", "_VD_CCD", preroll)           # Change Path to VDF
#   LoadVirtualdubPlugin("D:\VDUB\ccd_64bit.vdf", "_VD_CCD", preroll)           # Change Path to VDF   ## Getting Error OXC1 for 64 bit VDF plugin
    result = clip._VD_CCD(threshold,multithreading?1:0)
    return (ShowNoise) ? result.Subtract(clip) : result
}

SHOWNOISE=False

AviSource("D:\parade.avi")

# Added, FIX WEIRD stuff
MOD=16                            
Crop(0,0,Width/MOD*MOD,height/MOD*MOD)

ConvertToRGB32(matrix="rec601")
VD_CCD(shownoise=SHOWNOISE)
NOTE, the VDF is 8 bit RGB32 only.

EDIT: Added ShowNoise simulated arg, not sure if working ok. [test clip giving weird result]

Here wierd results, weird at top of frame, maybe again VdubFilter.dll problem [there is some color variation in the main grey block]


EDIT: VD_CCD(threshold=0,shownoise=true) should provide no change, but gives same weird problem at top of frame.


EDIT: This fixed problem if before the function call, weird stuff gone [MOD=8 dont fix it]
Code:
MOD=16
Crop(0,0,Width/MOD*MOD,height/MOD*MOD)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th June 2020 at 10:32.
StainlessS is offline   Reply With Quote
Old 14th June 2020, 15:21   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Added AMP arg,

Code:
# 64 bit VDF fails with error 0xC1, but filter works OK in VDUB2 x64, possible AVS+ VDubFilter.dll problem.

# VDub GUI "Show Noise" and "Disable" args not available external to VDUB, ie not usable in Avisynth.
# VDF accepts only RGB32
Function VD_CCD(clip clip, int "threshold", bool "multithreading",bool "ShowNoise",Bool "Amp",Int "preroll") {
    threshold      = Default(threshold,30)                                      # Default 30 as in Vdub
    multithreading = Default(multithreading,true)                               # Default true
    ShowNoise      = Default(ShowNoise,False)                                   # Simulated
    Amp            = Default(Amp,True)                                          # Amplify if ShowNoise
    preroll        = Default(preroll,1)                                         # We've given default of 1 frames pre-rolled, maybe only 0 needed.
    Assert(clip.IsRGB32,"VD_CCD: Need RGB32")
    LoadVirtualdubPlugin("D:\VDUB\ccd_32bit.vdf", "_VD_CCD", preroll)           # Change Path to VDF
#   LoadVirtualdubPlugin("D:\VDUB\ccd_64bit.vdf", "_VD_CCD", preroll)           # Change Path to VDF   ## Getting Error OXC1 for 64 bit VDF plugin
    result = clip._VD_CCD(threshold,multithreading?1:0)
    return (!ShowNoise) ? result : (!amp) ? result.Subtract(clip) : result.Subtract(clip).Levels(128-8,1.0,128+8,0,255,coring=false)
}

THRESHOLD=30
SHOWNOISE=true
AMP      =true

AviSource("D:\parade.avi")

# FIX VDubFilter.dll Weird BUG, but not the x64 bug
MOD=16
Crop(0,0,Width/MOD*MOD,height/MOD*MOD)

ConvertToRGB32(matrix="rec601")
VD_CCD(threshold=THRESHOLD,shownoise=SHOWNOISE,amp=AMP)


NOTE, RGB Interleaved is internally upside down, so weird stuff at top of frame is actually near end of frame buffer.

EDIT: OOps, used AMP center 126, changed to 128 [subtract for YUV TV levels Y is 125.5 rounded to 126, but we are in RGB so need 128]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 14th June 2020 at 16:53.
StainlessS is offline   Reply With Quote
Old 14th June 2020, 17:52   #7  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by StainlessS View Post
Asking for anybody to emulate CCD without some source code is also improbable outcome
I am not a programmer, but I was able to decompile the plug-in file "ccd_64bit.vdf" using the program:
Snowman
https://derevenets.com

Last edited by zybex; 18th June 2020 at 09:08.
zybex is offline   Reply With Quote
Old 14th June 2020, 17:57   #8  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
My primary goal was to get the plugin to work directly in YV12 mode, without the need for ConvertToRGB32 operation.
Each color space conversion blurs the picture and distorts some colors, especially red.
zybex is offline   Reply With Quote
Old 14th June 2020, 18:53   #9  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
So far i have found a way out:

As a replacement for the "CCD - Camcorder Color Denoise" filter in AVISynth, I selected the "TBilateral" filter parameters to make it work only to suppress Chroma noise.
With such a line, the result of "TBilateral" is almost identical to "CCD - Camcorder Color Denoise" with Threshold=20:

TBilateral (diameterL=3, diameterC=11, sDevL=0, sDevC=3.0, iDevL=0, iDevC=7.0, csL=1.0, csC=1.0, d2=false, chroma=true, gui=false, kernS=2, kernI=2, resType=0)
zybex is offline   Reply With Quote
Old 14th June 2020, 19:07   #10  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
But the TBilateral filter is slow.

My next dream wish is:
So that in the fast-running filter DGDecNV> DGDenoise (fast stand-alone CUDA filter that implements NLM denoising)
made a separate adjustment of parameters for Chroma noise reduction.
Now there the noise reduction parameters for Chroma and Luma can only be the same, which does not allow to achieve an ideal result.

http://rationalqm.us/dgdecnv/dgdecnv.html
http://rationalqm.us/board/viewtopic.php?f=14&t=506

DGDenoise(clip c, float strength, float blend, bool chroma, int searchw, int device)
Attached Files
File Type: zip DGDecodeNVManual.zip (7.8 KB, 105 views)
zybex is offline   Reply With Quote
Old 14th June 2020, 19:23   #11  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
You can run DGDenoise twice and use Mergexxx.

chromadenoise = DGDenoise(strength=whatever)
lumadenoise = DGDenoise(strength=whatever2)
lumadenoise.MergeChroma(chromadenoise)
__________________
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 14th June 2020, 20:02   #12  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by Boulder View Post
You can run DGDenoise twice and use Mergexxx.
Thanks, I will try this option later.

But how to make DGDenoise work only with Chroma, without Luma ?

Last edited by zybex; 14th June 2020 at 20:10.
zybex is offline   Reply With Quote
Old 14th June 2020, 21:57   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Using a decompiler to re-code a plugin would I think constitute Code Theft.
You would need to find Public domain or Open Source, source code, or algorithm.

DGDenoise for chroma, might try look here(I dont use DGdenoise):-

http://avisynth.nl/index.php/Swap
and here:- http://avisynth.nl/index.php/Extract
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2020 at 00:08.
StainlessS is offline   Reply With Quote
Old 15th June 2020, 04:54   #14  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by StainlessS View Post
the filter you mention relies on RGB to do its thing, YUV conversion would likely not work as well or at all.
Autor of CCD wrote at 2018:
"CCD uses the advantages of RGB, so translation into other formats is possible only in sham, inside you still have to translate into RGB."
(translated from Russian)

Nevertheless, I have already managed to achieve a very similar result directly in the YV12 mode using the special Chroma setting of the "TBilateral" filter, as I wrote above.
zybex is offline   Reply With Quote
Old 15th June 2020, 05:09   #15  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by zybex View Post
Thanks, I will try this option later.

But how to make DGDenoise work only with Chroma, without Luma ?
chromadenoise = DGDenoise(strength=whatever)
MergeChroma(chromadenoise)
__________________
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 June 2020, 05:15   #16  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by StainlessS View Post
Using a decompiler to re-code a plugin would I think constitute Code Theft.
You would need to find Public domain or Open Source, source code, or algorithm.
Unfortunately for many years the author of CCD has not yet published either the source code or the algorithm of work.
I think that he uses the secret technologies of ancient or extraterrestrial civilizations :-)

Updated 18 June:
Sources here:
https://forum.doom9.org/showthread.p...10#post1916010

Last edited by zybex; 18th June 2020 at 09:11.
zybex is offline   Reply With Quote
Old 15th June 2020, 05:20   #17  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by Boulder View Post
chromadenoise = DGDenoise(strength=whatever)
MergeChroma(chromadenoise)
Thank you, wise Boulder.
zybex is offline   Reply With Quote
Old 15th June 2020, 06:12   #18  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by StainlessS View Post
Interesting option.
Thanks.
It remains only to figure out which combination of filter commands "Extract" and "Swap" need to be composed to process only Chroma through DGDenoise.
zybex is offline   Reply With Quote
Old 15th June 2020, 07:01   #19  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Quote:
Originally Posted by zybex View Post
Interesting option.
Thanks.
It remains only to figure out which combination of filter commands "Extract" and "Swap" need to be composed to process only Chroma through DGDenoise.
DGDenoise only supports YV12 or YUV420P16. The following method allows you to denoise each chroma channel independently, sometimes one has more noise then the other.

For YV12 do something like:
Code:
Source

Y = Last
U = UToY().DGDenoise(strength=0.20, chroma=false) # chroma processing is already set to false by default 
V = VToY().DGDenoise(strength=0.25, chroma=false)

YToUV(U,V,Y)
For YUV420P16 you have to use ShowU/ShowV and CombinePlanes.
Code:
Source
ConvertBits(16)

Y = Last
U = ShowU(pixel_type="YUV420P16").DGDenoise(strength=0.20, chroma=false)
V = ShowV(pixel_type="YUV420P16").DGDenoise(strength=0.25, chroma=false)

CombinePlanes(Y,U,V, planes="YUV", source_planes="YYY", sample_clip=Y) # instead of 'sample_clip' you can also you pixel_type="YUV420P16"

Last edited by Reel.Deel; 15th June 2020 at 07:45.
Reel.Deel is offline   Reply With Quote
Old 15th June 2020, 11:21   #20  |  Link
zybex
Registered User
 
zybex's Avatar
 
Join Date: Apr 2007
Posts: 33
Quote:
Originally Posted by Reel.Deel View Post
For YV12 do something like
OK.
Many thanks.
zybex 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:53.


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