Friday, February 7, 2014

Batch denoising JPEG files with ffmpeg

I love PhotoScape! If your photoshop skills are not up to par, then you will like this program too. Its 'film effect' filters are amazing, but what I really like about this program is its Noise Reduction (clear skin) feature - your woman will love you for using it, especially on close-ups (less visible blemishes/pores/lines). However, this functionality is not available in batch editor mode (last time I checked). *sigh*

Fortunately, ffmpeg offers the next best thing, and it's called High Quality 3D Denoise.

Just create an empty text file, rename it to, like, "Denoise_JPEG_files_in_this_folder.bat", copy/paste the code below, set the appropriate ffmpeg path, tweak to taste, copy/paste the batch file into a folder full of jpeg files, and you're ready to go!

BTW, set the value for "AdditionalVideoFilters" to blank if you don't want the set filter.


<code starts after this line>

@echo off

: _______________________________________________

: This batch file will apply ffmpeg's High Quality 3D Denoise filter on all found image files in the current folder (subfolders included) and open the output folder. Don't forget to set ffmpeg's full path.

: _______________________________________________


: enter required/desired settings

: set ffmpeg path (required). use double quotes.
set ffmpeg="C:\~ En Masse\third party bin\ffmpeg-20131222-git-9b195dd-win32-static\bin\ffmpeg.exe"

: set LumaSpatial. practical range for a 640x480 image is 4-12. no quotes.
set LumaSpatial=12

: set image file types to search/process. note that all files will be converted to the set outputfile extension. no quotes.
set FileTypes=*.jpg, *.jpeg, *.bmp, *.png, *.tif, *.tiff

: output folder (subfolder). no quotes/spaces.
set OutputFolder=~Denoised

: output file name suffix. no quotes.
set Suffix=_Denoised

: output file extension (jpg, png, bmp, etc). no quotes.
set OutputExtension=jpg

: additional video filter (optional). this is for demonstration purposes only. precede each filter with a comma ','. you can set the value to blank if you don't want this feature. no double quotes at both ends.
set AdditionalVideoFilters=, curves=master='0.05/0.045 0.06/0.06 0.5/0.6'

: _______________________________________________

title %~n0

: create the output folder
md %OutputFolder%

: open the created output folder
start explorer.exe %OutputFolder%

: search and process
FOR /F "delims=" %%A IN ('dir /a:-d /b /o:n /s %FileTypes%') DO (
echo %%A
%ffmpeg% -threads 1 -y -f image2 -i "%%A" -f image2 -qscale:v 1 -vf "hqdn3d=luma_spatial=%LumaSpatial%: chroma_spatial=1: luma_tmp=1: chroma_tmp=1 %AdditionalVideoFilters%" "%OutputFolder%\%%~nA%Suffix%.%OutputExtension%"
)

exit




No comments:

Post a Comment