A configurable, flexible image processing library
Cornucopia
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.
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.
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.
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.
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.
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
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.