CTL Script: “Specific Luminosity Area Correction”

I made new CTL Script, As usual, its main purpose is restoration of scanned images of defective films or photographic prints. This script, named “Specific Luminosity Area Correction”, is luminosity area version of “Relative Color Area Correction”. Instead of relative color area, it adjusts the color or luminosity value of specific luminosity value area.

The image below is the dialog for this script.

The first two sliders set two thresholds to determine the brightness region. The next dropdown list is for determining editing area. “Inside the range” means that the editing range will be the range that takes values between the two thresholds. “Outside the range” means that the area other than the area between the two thresholds becomes the editing range.

Show Target Area check box is for preview of editing area.

Invert value check box is for inverting strength value of editing area. The strength value is determined by pixel luminosity value – lower threshold value (Inside the range) or absolute value of pixel luminosity value – nearer threshold value (Outside the range). If you check this check box, the value will be inverted.

Luminosity adjustment is for adjusting the pixel luminosity value. In default pixel luminosity will be adjusted with relative value. Minus value means adjusting darker, and plus value means lighter. However, if you check “Apply absolute value”, the specified value will be applied to pixel as luminosity value, and if the value is minus, it will be changed to 0.0 (black point). If you check “Apply absolute value”, it is recommended to check also “Apply uniform strength”.

Other parameters are basically same as “Relative Color Area Correction”.

[Basic operation example]

The image below shows the original sample image loaded into ART and this script selected.

Specifying the threshold as 1.00 to 0.072 and “Target area” as “Inside the range”, editing area preview will be as shown below.

Almost all of the sky of this image is selected.
In this setting, increasing red value makes following image.

Instead increasing red value, increasing Luminosity adjustment value will lead to the below result.

Changing “Target area” as “Outside the range” will lead to the editing area preview as below.

Almost all of the shadow area of this image is selected. We can see negative image of shadow area as editing area preview.
If you check “Invert value”, editing area preview will become as shown below.

We can see positive image of the shadow area as editing area preview.
Checking “Apply uniform strength” will lead to the editing area preview as below.

As you can see, this script is basically similar with parametric mask of Lightness in ART. However this script allows you much more precise control over the editing area and strength, which is definitively important for repairing scanned images of defective films or photographic prints, I think.


Editing example of using this script: dust spots removal

ART has spot removal tool, however if there are many spots in editing image it is very bothersome using spot removal tool to repair them. Large or long scratch noises are also difficult to use spot removal to remove them. With this script it is relatively easy to repair these noises at once.

  1. Original sample image with dust spots. We can see many dust spots in the image.

  1. In Color / Tone correction, select this script and make area mask to remove these spots.

  1. Check “Show target area”checkbox, and adjust thresholds, Gamma and strength parameters watching the preview image of editing area to make appropriate area .

  1. Adjust Luminosity adjustment value to remove these spots at once.

5)You may adjust R, G, B values as needed.

This is also applicable to monochrome images.


Hello Yasho,

Thanks for your script. Your second example - scratch removal - grabbed my attention as I’m scanning slides and negatives on a regular base.

The first photo I used is a scan of a half-frame image with a straight line it it, apparently a mechanical problem, recently taken with my latest camera, an Agfa Paramat (about 1965).

I was not able to remove that line, which shows up as a white line in the print.

I was somewhat luckier with the second photo I tried. I bought a set of slides in a recycle shop some years ago. They were made during a trip in Egypt by an unknown photographer, I guess around 1975. Here is one of them, a boat trip on the Nile.

When zoomed in, there are quite some dust spots visible in the air.

I made an area mask on the sky on the right.

Here’s how it looks like, without your CTL script.


And here with your script activated.


Some spots disappeared, but the longer one in the middle (comet form) did not.

Might be that I need to spend some more time to find out what your script really can do.

Hi, Paul,

To remove dust spots, you need to select an area mask of areas with similar brightness levels. In my sample image above, I chose a horizontal area mask because there is a vertical brightness gradient in the sky.
Your cropped sample image also has a clear vertical gradient, and the long dust spot has similar brightness level as the non-spot areas at the top of the image. To remove the long dust spot, you need to create two separate area masks, which must be edited separately.

The method in below link is better way to remove dust in the sky.

Hello Yasuo,

Sorry for the late answer, had some busy days here.

Removing dust with your script works indeed better when using several area masks (that was actually my afterthought when I used your script for the first time). But still no “perfect” solution for me.

I read your Gimp article as well, but for me that’s way too complicated. Using the clone or healing tool is easier and that works usually very well.

There’s still another option, using ART. The more time you spend on it, the better the results.

  1. Navigate to your favorite dust spot.
  2. Activate Local edits.
  3. Color similarity mask > Choose color next to the dust spot.
  4. Brush mask > mark dust spot.
  5. Adapt shadows / midtones so that spot disappears.
  6. Activate pencil in Brush mask and click on other nearby spots, they will disappear as well.

This procedure closely resembles the retouching technique for baryte prints using special gray inks and several brushes !

Again, not perfect but very usable. The lighter spots can be avoided by spending more time on color picking and brightness settings, or by using several or many masks.

Here are three screenshot. First is original slide at 100%, second is the result with your CTL script, third is my brush attempt.


Hi, Paul,
Thank you for taking your time.

If there are not many spots in editing image, I usually use spot removal tool in ART and I am satisfied with its functionality except we cannot select a shape for the editing area other than a circle.

The problem is images with many spots.

My script’s weak point is that it cannot take color value of periphery area of spots. So, it needs to divide editing area in gradient area. In my understanding it is the limit of CTL script specifications.

To overcome this problem, the alternative I came up with is the method to use Gaussian blur in GIMP and its result is successful, I believe. However, as you pointed out, its procedure is somewhat complicated.

I think it would be a desirable to automate the procedure using Python-fu. However the specifications of Python-fu are scheduled to change significantly in GIMP 3.0 and there is no published manual of Python-fu programing in GIMP 3.0. So I would like to leave this as a future topic.