## Summary

In this cookbook we show how to make a new compound tool by grouping together a set of existing tools. The new tool sharpens an image with unsharp masking operation. The operation combines the original and a blurred image so that the outcome appears to be sharper than the original image.

## Detailed description

Let us walk through the schema below top-down.

• The test image originates from the virtual camera configured in Image Source.
• The image is blurred slightly in Linear Filter Tool using Gaussian filter.
• The original and the blurred images are weighted and added up in Add Images Tool. The weights are calculated in the script as described below.
• A JavaScript Tool inputs a weight which determines how much sharpening is applied and calculates two scaling factors based on the weight, one for the original and the other for the blurred image. Sync input is only used for triggering the calculation. It can be connected to any output in the Image Source which emits a value on each image. For instance, Image and Image Count are such outputs. The parameters and the script code are shown below.

An example of Unsharp Masking operation is given below. Unsharp masking makes the boundaries of the letters more distinct.

## Sharpening Tool as a Compound

In this chapter we show how to group Linear Filtering, Image Addition and Script tools together as a single Unsharp Masking Tool and store it in your toolbox for future use.

Let's start by showing where we are aiming at. The goal is to create a single tool which can be connected directly to Image Source.

We begin by grouping the relevant tools as a compound. This is done by holding down Ctrl key and left-clicking on the tools of interest. Then release Ctrl and right-click to bring up the menu. Select Create Compound.

The input image is already connected to the selected compound so Image input is created automatically. Parameter Weight in the script tool must also be added to the set of inputs of the compound. This is done by connecting Weight to the little + sign on top of the compund box. First click on the white circle next to Weight parameter in the script tool. An arrow appears. Now just click on the + sign to create the parameter.

Likewise, Image output of Image Addition tool must be defined as the output of the compound tool. Just like above, click on the circle next to the output and connect it to the little x sign at the bottom of the compound box.

Now we are done with the compound. The inputs and the output are shown at top and bottom, respectively.

Right-click on the compound box and select Close Compound to hide details of the compound tool. Then right-click on the tool and select Tool Properties to change the name of the new tool. Click on the pencil icon and type new name Unsharp Masking.

Now you can save the new tool to the library so you can use it later in other projects. For this end, right click on the tool and select Save Tool.

Now the tool appears in User Tools section in the tool menu.

You can now drag and drop it on the canvas just like any native tool. The contents of the compound tool can always be examined by right-clicking Open Compound.