Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Image Processing

AlphaAtlas edited this page Nov 9, 2019 · 11 revisions

In the VapourSynth Editor, open the "ProcessImagesAuto.vpy" file in the "VapourSynthScripts" folder.

At the top, you can import all the scripts/functions you need, just like any other VapourSynth script. Scroll down a little, and you'll get to the "Main" and "Extra" options.

  • inputfolder is the folder Python will search for images in. Images in this folder won't be touched, and processed images will written to a mirrored directory in a separate folder.

  • filtermode can be set to either "filetype" or "similarimage." filetype gets all images that match a specific file extension, similarimage looks at one image and gets all files that match that image's dimensions and format. So if, for example, it's a 512x512 image with an alpha layer, 512x512 images without alpha layers will be skipped.

  • inputimagedir is the path of the image to match with the "similarimage" filter mode

  • inputformat is the file extension (like "png") to use with the "filetype" filter mode.

  • imgformat is the output file extension (like "png") to write files with assuming writing is enabled

  • showalpha and showoriginal will interleave alpha layers (if there are any) and a nearest-neighbor scaled version of the original image, for easy comparison. These extra images won't be written as images, but they will be included if you pipe all your images to a video file.

  • writeimages controls if processed images are actually written to disk.

  • The manual_sr_args section is for manually adding arguments to sr_args if you're using the super_resolution() mxnet filter. For example, manual_sr_args['block_w']=64 will overwrite the default horizontal block size in sr_args to 64.

  • You can give VapourSynth more RAM to play with using core.max_cache_size = (size in MB)

The ImageProcess and AlphaProcess functions are where the filtering happens. VapourSynth filters don't like sequences of images with mismatched formats, so before VapourSynth starts, a script groups images into clips sorted by their size and type, and calls those two functions on each clip.

  • "ImageProcess" handles the color planes of your image.

  • "AlphaProcess" processes the alpha layer as a grayscale image. If the size doesn't match, it'll be scaled with Spline36 to match the processed images, and if something else is off (like, for example, turning the alpha layer into an RGB image), VapourSynth will get angry and tell you what's wrong.

ProcessImages() runs and writes everything, and returns "clip" as a stream of frames with all your images, padded to the size of whatever the biggest image is, and converted to 10 bit RGB. If you want to do something to this stream, for whatever reason, do it after this function and before clip.set_output()

Random Tips

  • Don't forget that everything in "ImageProcess" and "AlphaProcess" has to be tabbed exactly once!

  • Some VapourSynth filters have a temporal component, meaning they work with more than one frame. This can be problematic with image processing scripts, so check your script with a single input image.

  • Images will pop up in the VapourSynth_Processing folder as they're written.

  • There's a Image_Formats.txt file showing the resolution and format of every image in the target folder. If any images are broken, there should also be an error file.