Demosaicing Script

In this article: A demosaicing script allows you to use a script to interpolate the mosaic of an image captured through Bayer Filter, instead of using one of the built-in demosaicing algorithms. Each demosaicing script defines the patterns of Bayer Filter which it supports along with the script which interpolates the mosaic, and the algorithm will be listed in the demosaicing drop-down field just like the built-in algorithms. Demosaicing scripts are supported by PixelViewer 2026.1 and later.

Creating and Managing

There are 2 ways to open dialog to manage demosaicing scripts:

Through Tools Menu

Windows/Linux Users

  1. Click at right hand side of toolbar.
  2. Click 'Tools > Manage Demosaicing Scripts…' in menu.

macOS Users

  1. Click 'Tools > Manage Demosaicing Scripts…' in menu at top of screen.

Through Rendering Parameters Panel

  1. Find the drop-down field of demosaicing in 'Rendering parameters' panel.
  2. Click [Create Script…] below the drop-down field.
If the current image is already demosaiced by a demosaicing script, you can click [Edit Script] below the drop-down field to edit that script directly. The image will be rendered again once the script is applied.

Defining the Algorithm

Besides the script itself, the following are defined by each demosaicing script:
  • Name
    The name of the algorithm shown in the drop-down field of demosaicing.
  • Supported Bayer Patterns
    The patterns of Bayer Filter which the script is able to interpolate. The algorithm will be listed in the drop-down field of demosaicing only when the pattern of the current image is one of them. A script written for a 2x2 pattern is able to support the 4x4 patterns as well by interpolating each sub mosaic of the image one by one.
  • Working Buffer Size per Pixel (Bytes)
    The number of bytes of each pixel of the buffer which the script keeps its own intermediate result in. Setting to 0 means that no buffer is needed, and the maximum value is 64. The buffer is allocated by the application before the script runs, which is why its size is defined here instead of being requested while the script is running.
  • Use Different Buffers for Input and Output
    Whether the demosaiced image is written into a buffer other than the one which the mosaic is read from or not. Clearing it lets the script interpolate the mosaic in place, which saves one buffer of the image, but the script must read the pixels beside a pixel before it writes that pixel.
The definitions above belong to the algorithm itself, and they are applied every time when the image is demosaiced by the script.

Scripting Basics

Please refer to Scripting in Application for the basics of scripting.
Unlike the other types of script, a demosaicing script runs on a background thread every time when the image needs to be rendered. Therefore, interacting with user is not supported inside a demosaicing script.

Languages

You can use the following languages to create Demosaicing Scripts:

Writing with an AI Tool

You can let an AI tool write the script for you. The Skill below teaches it the API of demosaicing scripts. It produces the script along with the settings to enter in the editor, which you copy into PixelViewer yourself. Please refer to Installing Skills for AI Tools to install it.
The AI tool cannot access PixelViewer. It only writes the script and tells you which settings to use.
A script is not sandboxed and runs with the same permission as PixelViewer. Please read and understand a script generated by an AI tool before enabling script execution.