Batch Denoise Script
This is a script to run Renderman's De-noise function to take already rendered .exr files and apply a filter to remove a small amount of noise from them.
​
The process to do so is as follows-
1. Locate where the script and .exr files are sitting.
- This script can be run from either cutter or by running the executable file also placed in the same folder.
2. Get a listing of all .exr files in the folder.
3. Write a script to take all listed .exr files and append the de-noise script to them.
- This is done by using f.write to write a seperate python script that can be executed.
4. Create a click-able file to run the de-noise process.
​
The script I created is as follows. It is very similar to the batch render script, but the command and the process for creating this script has been altered. Instead of using os.system to run the linux script, I wrote it using f.write to have the script write a separate script.
​
import os
import os.path
import inspect
import re
import glob
#1. Locate where the script is sitting
fullpath = inspect.getframeinfo(inspect.currentframe()).filename
dirpath = os.path.dirname(os.path.abspath(fullpath))
#2. Locate the .exr files.
glob_pattern = os.path.join(dirpath, '*.exr')
paths = glob.glob(glob_pattern)
paths.sort()
denoisepath = os.path.join(dirpath, 'render')
extensions = []
for s in paths:
ext = re.compile(r'(\w+)[._]+(\d+)[._]+exr')
found_it = re.search(ext, s)
if found_it:
extensions.append('%s' % found_it.group(2))
#3. Create run denoise script
filepath = os.path.join(dirpath, 'run_batch_denoise')
f = open(filepath, 'w')
#3a. Write out denoise command.
f.write('denoise --crossframe -v variance -f default.filter.json %s.{' % dirpath)
for e in extensions:
f.write('%s,' % e)
f.seek(-1, os.SEEK_END)
f.truncate()
f.write("}\n")
f.write('\n')
f.write('read\n')
f.close()
#4. Complete.
print '"run_denoise_render" successfully created'
An issue with this script that I'd still like to figure out is how to put the filtered .exr files in a seperate folder so that if the script is run again, it will not filter the "filtered" files but only those labelled "variance".
​
This "run_batch_denoise" script that appears in the images folder creates a readable python code that looks like this.
​
denoise --crossframe -v variance -f default.filter.json /i-drive/stuhome/maya/projects/default/images/tech312_v001_t01.{0001,0002,0003,0004,0005}
read
​
This script is then run until all .exr files have been processed.
​
