Python
Batch Denoise


main index


Introduction

When a script performs a "batch process" it does so by either:
  - directly editing a sequence of files, or
  - by writing a text file that indirectly references a number of files.

For this assignment you are to write a python script, named "make_denoiser.py", that when double clicked, or executed from a terminal, will create a script named "run_denoiser" containing a command of the following form.


denoise  --crossframe -v variance -f default.filter.json  FULLPATH_TO_IMAGES_DIR/IMAGE_NAME_variance.{0001,0002,0003}.exr 

The command consists of five parts,
1   denoise --crossframe -v variance -f default.filter.json
2   the full path to the directory containing the unfilter openexr images
3   the name of the unfiltered image
4   a list of the numeric file extensions, followed by
5   .exr


The purpose of the "run_denoiser" script is to reference a sequence of openexr image files so that Disney's utility program named denoise will filter each image. For example, suppose a directory has five unfiltered openexr images named,

H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_variance.0001.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_variance.0002.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_variance.0003.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_variance.0004.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_variance.0005.exr

After the "run_denoiser" script has finished filtering the following images would be created.

H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_filtered.0001.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_filtered.0002.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_filtered.0003.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_filtered.0004.exr
H:/maya/projects/images/test/v001_t01/test__shotCam_beauty_filtered.0005.exr

Algorithm

The following algorithm, operating recipe, assumes the "make_denoiser.py" script has been saved in the same directory as the unfiltered (varience) openexr images.

  1   determine the full path to the images directory,
  2   create a list of the full paths of the ".exr" images,
  3   sort the list,
  4   get the name of the first image (excluding the numeric and ".exr" extensions,
  5   depending on the OS open a file named "run_denoiser" or "run_denoiser.bat",
  6   write part 1, 2 and 3 of the command,
  7   make a string of comma separated numeric extensions,
  8   write the string (part 4 of the command),
  9   write part 5 of the command,
  Finally, close the file and depending on the OS give it "execute" permissions.