A configurable, flexible image processing library


Article from Issue 253/2021

Behind G'MIC's deceptively simple interface hides a mighty image processing framework. While mastering G'MIC can be a rather daunting proposition, here's how to get started.

GREYC Magic for Image Computing (G'MIC) [1] offers a seemingly limitless library of simple and advanced filters you can apply to images. Filter, in this case, is a bit of a misnomer. Filters are usually associated with presets that modify an image's overall appearance, and normally they don't offer much in terms of customization. G'MIC filters couldn't be more different. Think of G'MIC filters as actual tools that are designed to perform specific image manipulation tasks. Each tool offers a number of configurable options that allow you to achieve the optimal result. More important, unlike traditional filters, G'MIC tools can be used not only to change the overall look of an image but also to perform a multitude of other tasks, from making basic adjustments (brightness, contrast, saturation) to denoising and applying custom CLUT presets.

Objectively, not all of the G'MIC filters are equally useful, but as a photographer or a digital artist, you will likely find plenty of powerful filters in G'MIC's library worth adding to your image processing and manipulation toolbox. In this article, I'll show you how to put G'MIC to practical use.

Installation and First Steps

Although G'MIC is available as a command-line tool and a web service, you will most likely want to use it as a regular graphical application. You'll find the G'MIC plugin for Gimp and Krita in the official repositories of many mainstream Linux distributions. To plug G'MIC into Gimp on Ubuntu, run the command:

sudo apt install gmic-gimp

Doing the same on openSUSE is equally simple:

sudo zypper in gimp-plugin-gmic

If you happen to use digiKam, you'll be pleased to learn that the latest version of digiKam comes with G'MIC. However, keep in mind that not all G'MIC tools work in digiKam. Since digiKam doesn't support layers and masks, the G'MIC tools that require this functionality won't work.

The G'MIC plugins and the digiKam version have the same easy-to-use graphical interface. The interface (Figure 1) is split into three parts: the preview pane to the left, the list of all available tools in the middle, and the options section to the right. G'MIC offers more than 500 filters that are grouped into categories by their functionality, making it easier to explore the library and find the tool you need. In addition, you can use the Search field to search for a specific tool by name. For faster access to frequently-used tools, use the Fave button to add them to the Faves menu.

Figure 1: G'MIC features a simple interface putting all its tools at your fingertips.

Exploring G'MIC

Many G'MIC tools come from external contributors. The sheer number and variety of contributions is a testament to G'MIC's power and flexibility. However, many tools provide no documentation to help you to figure out what certain options do. It's not a big issue for simple tools such as Basic Adjustments, especially if you are familiar with image editing fundamentals. But to master more advanced tools, prepare to do some experimenting. The good news is that nothing is applied to the currently opened image until you hit the OK button. And even then, you should be able to undo the applied modifications in the host application. When working with G'MIC, keep in mind that the preview doesn't always provide an accurate representation of the applied filter. So it's better to treat the preview as a rough approximation rather than a pixel-perfect rendering.

Before you start exploring G'MIC's advanced functionality, it makes sense to start with simple tools that have only a few adjustable parameters, such as Colors | Color Balance and Colors | Basic Adjustments. Color Balance provides a quick and simple way to adjust white balance by selecting the neutral color, while Basic Adjustments lets you adjust brightness, contrast, and saturation. Some G'MIC tools have overlapping functionality. The Colors | Auto Balance tool, for example, is very similar to Colors | Color Balance, but it has more adjustable parameters. In other words, G'MIC often offers several paths to achieving the desired result. More important, the basic tools in G'MIC don't merely replicate the functionality available in host applications such as Gimp and digiKam. Instead these tools nicely complement an application's existing features.

It would be impossible to describe everything G'MIC has to offer, so let's focus on a couple of tools that most users will likely find handy. If you are looking for a quick and easy way to liven up your photos, you will appreciate a comprehensive library of ready-made filters tucked under Colors | Simulate Film (Figure 2). Here, you will find plenty of effects to play with, from Black & White for emulating a wide range of classic black-and-white films to Instant [Consumer] for mimicking iconic Polaroid instant films. You can apply each filter as it is, or you can adjust the available parameters first. For example, if the filter is too strong for your taste, you can reduce its strength using the appropriate slider.

Figure 2: G'MIC offers plenty of high-quality presets to choose from.

If you have your own presets in the Hald CLUT format, you can apply them to the currently opened image with Colors | Apply External CLUT. If you don't have Hald CLUT files, G'MIC comes with a tool that allows you to generate Hald CLUT files from existing edits (Figure 3). To use this tool in Gimp, open the source image in Gimp and create a new layer by choosing Layers | New from Visible. You should see the new layer called Visible in the Layers pane. Make sure that this layer is on top and selected, and then apply the desired color adjustments. Choose Filters | G'MIC-Qt, and then switch to the Colors | CLUT from After-Before Layers tool. Select All visible from the Input layers drop-down list and New image from Output mode. You should see a Hald CLUT table in the preview pane. Press OK to generate a Hald CLUT file, save the file in PNG format, and you are done. Now you can apply the freshly-baked Hald CLUT file to a photo using Colors | Apply External CLUT.

Figure 3: You can use G'MIC to generate your own Hald CLUT presets.

Both digiKam and Gimp offer simple tools for removing unwanted objects from images. But though they can help you to remove dust particles and blemishes, these tools fall short when it comes to removing large and complex objects. Enter the G'MIC Inpaint tool (Figure 4), which lets you make objects disappear without too much effort. The way it works is rather straightforward: Use a certain color to mask the unwanted object, and then let Inpaint do its job.

Figure 4: Removing those pesky humans is easy with the Inpaint tool.

In Gimp, this requires a few simple steps. Open the desired image and set the background color to red (the HTML notation value should be ff0000). Use the Lasso tool to make a rough selection around the object you want to remove. Choose Edit | Fill with BG Color to fill the selection with the red color, and then choose Select | None to remove the selection. Open G'MIC by choosing Filters | G'MIC-Qt and select the Repair | Inpaint [Multi-Scale] tool. Specify the red color that matches the color you used for the mask in the Mask Color input field, and watch the masked object magically disappear in the preview window. G'MIC offers several Inpaint variants based on different algorithms. So if Inpaint [Multi-Scale] doesn't do a good job of removing the selected object, you can try other versions of the tool. And, of course, you can tweak the available parameters to achieve a better result.

Speaking of masks, G'MIC comes with a masking tool that makes it possible to quickly add masks based on a specific color. This tool can come in useful if you need to make adjustments to a specific area of an image, such as making the sky in the image brighter, desaturating a bright red car, or replacing one color with another one. To create a mask in Gimp, choose Filters | G'MIC-Qt, switch to the Colors | Color Mask [Interactive] tool, and press Apply (Figure 5). This opens a separate window where you can use the mouse to select the desired color. Mouse over the area you want to mask and right-click on it. To select a larger area, press and hold the right mouse button and drag the pointer across the area you want to select. Keep pointing and clicking until you've selected the entire area. If you accidentally select an area that shouldn't be included in the mask, point to it and left-click to remove it from the mask. Use the R key to reset the mask completely. Sometimes it can be difficult to see the mask's exact boundaries; you can use the Space or Tab key to switch between different viewing modes to give you a better preview of the current selection. When you are finished, close the preview window, and you should see a new layer with the mask in the Layers pane of Gimp.

Figure 5: Creating a mask with the Color Mask tool.

It's Complicated

Because G'MIC does a good job of hiding the complexities of image manipulation behind a simple interface, it's easy to forget the serious science happening in the background. Take, for example, the Details | Sharpen [Deblur] tool. It's based on the Jansson Van-Cittert deconvolution algorithm, and it's mostly used for recovering blurry images in microscopy and astronomy. The available parameters allow you to control how the algorithm is applied. The Radius parameter specifies a standard deviation of the Gaussian kernel that is supposed to model the image's blur degradation. In practical terms, you would use a high radius for very blurry images and a small radius when the blur is low. The Jansson Van-Cittert algorithm is iterative, meaning it starts with a blurry image and converges toward the deconvoluted image through multiple iterations. The Iterations parameter allows you to specify the desired number of iterations. The blurrier the source image is, the more iterations are required to make it sharper. The Time Step parameter controls the maximum intensity variation (in R,G,B) between two consecutive iterations. Assuming an image has RGB values in range [0,255], the default value 20 specifies that the pixels cannot vary more than + or -20 in value between two iterations. To avoid sharpening the noise, you can use the Smoothness parameter to specify the weight of the regularization term. The noisier the image, the higher smoothness value you need.

Of course, you don't need to know the underlying theory in order to use this and other tools. Tweaking the available parameters and previewing the result is often the best way to learn how a specific tool works and what it can do for you. But uncovering the theory behind certain tools provides a fascinating insight into the science of image manipulation. As already mentioned, finding information about specific tools can be a bit of a challenge, but asking your questions on PIXLS.US [2] is a good place to start.

Buy this article as PDF

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

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Out-of-Bounds Photos

    Including out-of-bounds effects in slide shows and presentations is bound to get the undivided attention of the audience. Gimp has simple tools to create these image effects.

  • Photo Processing with GIMP

    Touch up your digital images with the GIMP image processing tool.

  • Introduction

    This month in Linux Voice.

  • Animation with GIMP

    Although developed for editing individual images, GIMP has everything you need to create perfect animations via plugins and scripts.

  • Krita Vs. MyPaint

    If you are looking for an open source drawing program, Krita and MyPaint both offer graphic tablet support and brushes. Deciding which one works best depends on your specific needs.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95