Gimp Luminosity Mini Tutorial - Remove Glare

in #photography5 years ago (edited)

One of the problems with photographing action figures is the glare created by the lighting due to the glossy finish on most plastic. This is one method of using Gimp to remove the glare with existing plugins and luminosity masking techniques. This method also will aide in preparing images for photogrammetry. I've combined all of these manual steps into a python script which I have linked at the bottom of the page for those who are interested.

Before and After

Open Image in Gimp

Use the filter under generic called luminosity masks. This may not be there by default and you may need to install the plugin.

Luminosity Masks Filter

This will create 9 new channels from the image that highlight the light variation from light (L) to dark (DDD)

New Channels Created

Create two duplicate layers of the original image, rename them so you can identify which layer has which mask you will add. Then right-click on the first duplicate layer and choose "Add Layer Mask". From here you can choose which channel you would like to add as a mask (L for the L layer). Repeat the process for the other duplicate layer, adding the other channel. (LL channel for the LL layer)

Duplicate Layers

You will see the masks added next to the image in the layer window. The original image you opened as the base layer is unchanged.

Masks Added

From here you can experiment with the different modes, opacity, color levels, etc for each layer. I've found good results when using the burn mode with the luminosity layers.
Experiment with Layers

Using these steps you should be able to remove 95%-100% of the glare from the lighting. Here is the link to the python-fu script that automates the steps listed above.

Download: python_fu_remove_glare.py

Code:


#!/usr/bin/env python

from gimpfu import *

def python_fu_remove_glare(image, layer):
        gimp.progress_init("Creating layers " + image.name + "...")
        # call script-fu plugin to create the luminosity channels
        pdb.script_fu_sg_luminosity_masks(image, layer)
        # create new layers for L and LL masks
        newLayerL = layer.copy() 
        newLayerLL = layer.copy()  
        newLayerL.name = "L Layer"
        newLayerLL.name = "LL Layer"
        newLayerL.mode = BURN_MODE
        newLayerLL.mode = BURN_MODE
        image.add_layer(newLayerL, 0) 
        image.add_layer(newLayerLL, 1)   
        
        
        # get the list of channels
        for x in image.channels:
            # add the masks to the layers
            if(x.name.startswith(('L-'))):  
                pdb.gimp_image_set_active_channel(image, x)
                maskL = pdb.gimp_layer_create_mask(newLayerL, 6)
                pdb.gimp_layer_add_mask(newLayerL, maskL)
               
            if(x.name.startswith(('LL-'))):  
                pdb.gimp_image_set_active_channel(image, x)
                maskLL = pdb.gimp_layer_create_mask(newLayerLL, 6)
                pdb.gimp_layer_add_mask(newLayerLL, maskLL)
     
        
register(
    "python_fu_remove_glare",
    "Remove light glare from image",
    "Using the luminosity masks, create new layers with L, LL masks, set the mode to burn",
    "Jed Vargo",
    "Jed Vargo",
    "2019",
    "<Image>/Filters/Generic/_Remove Glare",
    "*",     
    [],
    [],
    python_fu_remove_glare)

main()

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65144.58
ETH 2627.08
USDT 1.00
SBD 2.83