Adding new functions with GIMP plugins

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Rescale, Texturize, and Synthesize

Rescaling images might be an easy action for users, but it can result in some quirks on closer inspection. One of these relates to so-called gamma errors [25]. A good solution for GIMP is ImageScaler [26] [27].

The Imagescaler plugin (Figure 17) is based on Python and C, but it is woefully slower in execution than the generic code. For interpolation, the plugin provides the existing GIMP algorithms from "none" to "cubic." Meanwhile, the "error" in the gamma treatment was reported as a bug and will be taken into account with the next version of GIMP.

Figure 17: This plugin allows scaling considering the gamma value.

Two solutions to a different aspect of scaling are handled by Upsize [28] by Adam Turcotte. When enlarging images, either artifacts can be minimized or the sharpness can be optimized. Special algorithms exist for both methods: "Interpolatory Box Filtered Natural BiQuadratic Histosplines" for soft transitions and "Natural BiQuadratic Histosplines" for optimal sharpness, but they don't belong to the GIMP standard. The Upsize plugin implements them both.

Installation is easy with gimptool-2.0 --install upsize_0.c , assuming the required packages are present. The associated menu item appears as Upsize in the Image menu. The results of these plugins are readily apparent, as a direct comparison shows (Figure 18).

Figure 18: Soft scaling and optimized sharpness are shown compared with the original image.

For images in PPM format, there are two standalone programs of this plugin. The source code is at the same URL [28], but you have to grab the eanbqh.tar.gz file. The installation requires you to compile with GCC using the following:

$ gcc -o eanbqh8 eanbqh8.c -fomit-frame-pointer -O2 -Wall -march=native -lm

after unpacking for the 8-bit version and

$ gcc -o eanbqh16 eanbqh16.c -fomit-frame-pointer -O2 -Wall -march=native -lm

for the 16-bit version.

These applications are easy to use. Typing

$ eanbqh8 input.ppm output.ppm -h width

scales to the desired width, while

$ eanbqh8 input.ppm output.ppm -d width x height

scales to the desired format. Using

$ eanbqh8 input.ppm output.ppm -s factor

and

$ eanbqh8 input.ppm output.ppm -p percent

scales using a scaling factor and a percentage, respectively.

Scale2x [29] from Trialforce was specially developed for scaling smaller bitmaps to a factor of two. The project is currently hosted at SourceForge [30], which has further details.

The Liquid Rescale [31] lets you adjust the width of selected regions of an image and remove undesired elements unobtrusively. The plugin analyzes the image so that the regions with "minimal energy" are recognized as lines. You can find a full explanation of how this works online [32].

Creating Textures

Textures are patterns that – despite looking repetitive – don't have any periodicity. In the past, it was common to look to nature for suitably large images. Then, an attempt was made to mix different parts of the pattern to increase the size. Today, special algorithms do the job.

Manu Cornet [33] together with Jean-Baptiste Rouquier developed the Texturize plugin [34] especially for this purpose. The algorithm uses quite a bit of processing, so creating a pattern can sometimes take hours. The plugin omits a preview for that reason. It's best to experiment with smaller patterns first before graduating to larger ones.

The algorithm cannot create output images with alpha channels. If the margins are of uniform color, however – preferably a color not found in the motif itself – they can be quickly removed with the (global) color selection if needed. High values for the overlap have better results, but they also have a more pronounced tendency to periodicity, as Figure 19 shows.

Figure 19: The influence of overlapping appears in this example: default value (100), output image, and increased overlapping (300).

A similar approach to that of the Texturize plugin is used in the Resynthesizer plugin [35]. This plugin has its own homepage [36] that describes its features. There are three basic applications for this plugin:

  • Small textures can be enlarged virtually in any way, as with Texturize.
  • Unwanted objects can be removed from images by being obscured by surrounding material.
  • Textures can be applied to images so you can modify them.

The Resynthesize option can be found under Filters | Map . The plugin operates over a two-part interface (Figure 20). Figure 21 shows its effect and the influence of its parameters.

Figure 20: The standard GUI of the Resynthesize tool displays all functions on two tabs. The options under "Tweaks" control the algorithm in detail.
Figure 21: The Resynthesize tool in action. The original image is shown above left and next to it with the option Fit output to bordering pixels. Below left shows the Make horizontally tileable and Make vertically tileable options, together with Fit output to bordering pixels on the right.

The additional features are in several scripts: smart-sharpen uses Resynthesize to sharpen the image, smart-enlarge reduces and enlarges images and smart-remove allows removing image sections (Figure 22). This script adds the Heal Selection… to the Enhancements menu. The plugin version hosted by GitHub [37] includes a few extensions. A different approach to removing offending parts of images comes from Interpolate [38]. The application has a tutorial that can be found online [39].

Figure 22: Heal Selection and other processes often create amazing results. Minor artifacts are still visible but only if you carefully compare the modified image to the original. These can often be eliminated with little handiwork (and with the clone, heal, and blur tools).

Buy this article as PDF

Express-Checkout as PDF
Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content