From 91663f92e5f47d06cfda88af263b3f3199e64f8b Mon Sep 17 00:00:00 2001 From: Sofus Rose Date: Mon, 27 Jun 2016 01:33:53 -0400 Subject: [PATCH] Added removegrain ffmpeg filter denoiser. All right, I think that's enough denoisers :). --- README.md | 8 +++++- configs/atadenoise-test.conf | 11 +++++---- configs/template.txt | 1 + convmlv.sh | 48 ++++++++++++++++++++++++++++++------ 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index eaa2a77..34fdbc0 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,15 @@ OPTIONS, RAW DEVELOPMENT: --> Spacial/Temporal (S/T). S will soften/blur/smooth, T will remove noise without doing that but may create artifacts. --> Luma/Chroma (L/C). L is the detail, C is the color. Each one's denoising may be manipulated Spacially or Temporally. - --> Options: -:- + --> Option Value: -:- --> Weak: 2-1:2-3. Medium: 3-2:2-3. Strong: 7-7:5-5 + -G [i-i-i-i] REM_NOISE - Yet another spatial denoiser, with 4 choices of 24 modes. + --> See https://ffmpeg.org/ffmpeg-filters.html#removegrain for list of modes. + + --> Option Value: --- + --> I truly cannot tell you what values will be helpful to you; there are too many... Look at the link above! + -g [0:4] SPACE - Output color transformation. --> 0: Linear. 1: 2.2 (Adobe RGB). 2: 1.8 (ProPhoto RGB). 3: sRGB. 4: BT.709. diff --git a/configs/atadenoise-test.conf b/configs/atadenoise-test.conf index 8b35b38..8bd5aa3 100644 --- a/configs/atadenoise-test.conf +++ b/configs/atadenoise-test.conf @@ -17,7 +17,7 @@ PYTHON python3 #~ THREADS 1 ### <------------------ OUTPUT OPTIONS ------------------> -IMAGE +#~ IMAGE IMG_FMT 0 MOVIE @@ -27,8 +27,8 @@ PROXY 0 KEEP_DNGS -FRAME_RANGE 300-310 -UNCOMP +FRAME_RANGE 300-350 +#~ UNCOMP ### <------------------ RAW OPTIONS ------------------> DEMO_MODE 2 @@ -36,15 +36,16 @@ DEMO_MODE 2 HIGHLIGHT_MODE 0 #~ TEMP_NOISE 0.15-0.04 #~ HQ_NOISE 7-7:5-5 +REM_NOISE 1-1-1-1 -SPACE 0 +SPACE 3 ### <------------------ COLOR OPTIONS ------------------> WHITE 1 ### <------------------ FEATURE OPTIONS ------------------> -DESHAKE +#~ DESHAKE #DARKFRAME ./df.darkframe #~ LUT /home/sofus/subhome/src/convmlv/test_footage/girl_lut_test.cube diff --git a/configs/template.txt b/configs/template.txt index 8862dae..53a384f 100644 --- a/configs/template.txt +++ b/configs/template.txt @@ -41,6 +41,7 @@ CHROMA_SMOOTH 1 WAVE_NOISE 50 TEMP_NOISE 0.03-0.04 HQ_NOISE 2-1:2-3 +#REM_NOISE 1-1-1-1 SPACE 3 #SHALLOW diff --git a/convmlv.sh b/convmlv.sh index b246424..717598f 100755 --- a/convmlv.sh +++ b/convmlv.sh @@ -132,12 +132,14 @@ setDefaults() { #Set all the default variables. Run here, and also after each AR FFMPEG_FILTERS=false #Whether or not FFMPEG filters are going to be used. TEMP_NOISE="" #Temporal noise reduction. tempDesc="" - LUT="" + LUT="" #lut3d LUT application lutDesc="" - DESHAKE="" + DESHAKE="" #deshake video stabilisation. deshakeDesc="" HQ_NOISE="" #hqdn3d noise reduction. hqDesc="" + REM_NOISE="" #removegrain noise reduction + remDesc="" } setDefaults #Run now, but also later. @@ -240,9 +242,15 @@ OPTIONS, RAW DEVELOPMENT: --> Spacial/Temporal (S/T). S will soften/blur/smooth, T will remove noise without doing that but may create artifacts. --> Luma/Chroma (L/C). L is the detail, C is the color. Each one's denoising may be manipulated Spacially or Temporally. - --> Options: -:- + --> Option Value: -:- --> Weak: 2-1:2-3. Medium: 3-2:2-3. Strong: 7-7:5-5 + -G [i-i-i-i] REM_NOISE - Yet another spatial denoiser, with 4 choices of 24 modes. + --> See https://ffmpeg.org/ffmpeg-filters.html#removegrain for list of modes. + + --> Option Value: --- + --> I truly cannot tell you what values will be helpful to you; there are too many... Look at the link above! + -g [0:4] SPACE - Output color transformation. --> 0: Linear. 1: 2.2 (Adobe RGB). 2: 1.8 (ProPhoto RGB). 3: sRGB. 4: BT.709. @@ -502,6 +510,18 @@ evalConf() { hqDesc="3D Denoiser" FFMPEG_FILTERS=true ;; + "REM_NOISE") + vals="$(echo "${line}" | cut -d$' ' -f2)" + + m1=`echo "${vals}" | cut -d$'-' -f1` + m2=`echo "${vals}" | cut -d$'-' -f2` + m3=`echo "${vals}" | cut -d$'-' -f3` + m4=`echo "${vals}" | cut -d$'-' -f4` + + REM_NOISE="removegrain=m0=${m1}:m1=${m2}:m2=${m3}:m3=${m4}" + remDesc="RemoveGrain Modal Denoiser" + FFMPEG_FILTERS=true + ;; "SPACE") mode=`echo "${line}" | cut -d$' ' -f2` case ${mode} in @@ -583,7 +603,7 @@ parseArgs() { #Amazing new argument parsing!!! longArg() { #Creates VAL ret="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 )) } - while getopts "vh C: o:P: T: i t: m p: s: k r: d: f H: c: n: N: Q: g: w: l: S: D u b a: F: R: q K Y M -:" opt; do + while getopts "vh C: o:P: T: i t: m p: s: k r: d: f H: c: n: N: Q: G: g: w: l: S: D u b a: F: R: q K Y M -:" opt; do #~ echo $opt ${OPTARG} case "$opt" in -) #Long Arguments @@ -787,6 +807,18 @@ parseArgs() { #Amazing new argument parsing!!! hqDesc="3D Denoiser" FFMPEG_FILTERS=true ;; + G) + vals=${OPTARG} + + m1=`echo "${vals}" | cut -d$'-' -f1` + m2=`echo "${vals}" | cut -d$'-' -f2` + m3=`echo "${vals}" | cut -d$'-' -f3` + m4=`echo "${vals}" | cut -d$'-' -f4` + + REM_NOISE="removegrain=m0=${m1}:m1=${m2}:m2=${m3}:m3=${m4}" + remDesc="RemoveGrain Modal Denoiser" + FFMPEG_FILTERS=true + ;; g) mode=${OPTARG} case ${mode} in @@ -1085,15 +1117,15 @@ for ARG in "${FILE_ARGS_ITER[@]}"; do #Go through FILE_ARGS_ITER array, copied f setBL=true joinArgs() { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } - + #Construct the FFMPEG filters. if [[ $FFMPEG_FILTERS == true ]]; then FINAL_SCALE="scale=trunc(iw/2)*${SCALE}:trunc(ih/2)*${SCALE}" - V_FILTERS="-vf $(joinArgs , ${DESHAKE} ${TEMP_NOISE} ${HQ_NOISE} ${LUT})" - V_FILTERS_PROX="-vf $(joinArgs , ${DESHAKE} ${TEMP_NOISE} ${HQ_NOISE} ${LUT} ${FINAL_SCALE})" #Proxy filter set adds the scale component. + V_FILTERS="-vf $(joinArgs , ${DESHAKE} ${TEMP_NOISE} ${HQ_NOISE} ${REM_NOISE} ${LUT})" + V_FILTERS_PROX="-vf $(joinArgs , ${DESHAKE} ${TEMP_NOISE} ${HQ_NOISE} ${REM_NOISE} ${LUT} ${FINAL_SCALE})" #Proxy filter set adds the scale component. #Created formatted array of filters, FILTER_ARR. - declare -a compFilters=("${tempDesc}" "${lutDesc}" "${deshakeDesc}" "${hqDesc}") + declare -a compFilters=("${tempDesc}" "${lutDesc}" "${deshakeDesc}" "${hqDesc}" "${remDesc}") for v in "${compFilters[@]}"; do if test "$v"; then FILTER_ARR+=("$v"); fi; done fi #Evaluate convmlv.conf configuration file for file-specific blocks.