Skip to content

Commit

Permalink
....testing for gimp3-fix-ca
Browse files Browse the repository at this point in the history
  • Loading branch information
JoesCat committed May 15, 2024
1 parent ffc3f3a commit 04a6563
Show file tree
Hide file tree
Showing 11 changed files with 1,490 additions and 889 deletions.
131 changes: 85 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Fix-CA
# GIMP3-Fix-CA

## Overview

Fix-CA is a [GIMP](http://www.gimp.org/) plug-in to correct Chromatic Aberration
(CA). For a general explanation about Chromatic Aberration, you can find
information from
[Wikipedia](http://en.wikipedia.org/wiki/Chromatic_aberration).
Fix-CA is able to fix Lateral CA colored fringing caused by light travelling
through lenses, and Directional CA caused by light travelling through dense
material such as glass and water.
GIMP3-Fix-CA is a [GIMP](http://www.gimp.org/) plug-in to correct Chromatic Aberration
(CA). For a general explanation about Chromatic Aberration, you can find information
from [Wikipedia](http://en.wikipedia.org/wiki/Chromatic_aberration).
GIMP3-Fix-CA can fix Lateral CA colored fringing caused by light travelling through
lenses, and Directional CA caused by light travelling through dense material such as
glass or water.

This plug-in was written by Kriang Lerdsuwanakij [email protected]
and is distributed under [GNU General Public License Version 3](COPYING) (GPLv3).
Several patches and improvements were later added in 2023,2024 by Jose Da Silva.
GIMP2-Fix-CA was written by Kriang Lerdsuwanakij [email protected], and
several patches and improvements were later added in 2023,2024 by Jose Da Silva.
GIMP3-Fix-CA uses a lot of the same code with modifications to run for GIMP3.
Fix-CA is distributed under [GNU General Public License Version 3](COPYING) (GPLv3).


## Using Fix-CA
## Using GIMP3-Fix-CA

Fix-CA plug-in can be accessed via the menu 'Filters->Colors->Chromatic Aberration'
There are two different types of Chromatic Aberration that can be corrected by Fix-CA:
Lateral and Directional.

There are two types of Chromatic Aberration that can be corrected by GIMP3-Fix-CA:
Lateral and Directional.

### Lateral CA

Expand All @@ -45,12 +45,13 @@ Below is the image used to demonstrate Fix-CA plug-in capability

This is a photo of Wat Pathum Wanaram, a buddhist temple next to Siam Paragon,
a major shopping mall in Bangkok. The areas of interest are marked with green
rectangles. Note that the reduced size here is only for display purposes.
The actual processing is done on the full sized image (with green rectangles
left "as-is" on a different layer, unaffected by the plug-in).
rectangles. Note that the reduced size here is only for display purposes here.

Below are 200% zoom of the four areas. The chromatic aberration (CA) is
visible on the images as red and blue lines around bright area.
The actual processing is done on the full sized image (with green pixels left in
same positions "as-is", and the blue or red pixels are moved outwards or inwards.

Below are 200% zoom of the four areas before processing. The Chromatic Aberration
(CA) is visible on these images as red and blue lines around bright areas.

![](img-fix-ca/ex-zoom.jpg)

Expand All @@ -59,27 +60,42 @@ but can be quite visible when the image is cropped to a smaller area and then
expanded.

Invoking Fix-CA plug-in using the menu 'Filters->Colors->Chromatic Aberration'
With the settings shown below image (for version 2.1.0), much of the CA can be
eliminated (for version 3.0.0 blue and red settings are moved into group 'Lateral').
with the 'Lateral' settings shown below can help improve or this image.

![](img-fix-ca/fix-ca-dialog.png)

When you are going to correct for Lateral CA, you should look around the edges.

The corners tend to have the worst Lateral CA, and you begin correcting there.
If you correct one corner, the rest of the picture should look okay too, therefore
check the other corners and edges using preview ON/OFF as you look around.
If the image center is not the lens center, or some alignment is off, then you
will want to move the lens center around a little bit a little bit off center,
and then check the corners and edges again until it looks okay to you.
The poor man's zoom of the branches (shown below) is an example you can try where
the lens center is off-center, and the lens alignment may be a little skewed too.

In the dialog box, setting red to -1.5 will shift the red channel inward to
the maximum of 1.5 pixels. Here the positive number means moving outward,
while the negative number means inward. Since the orientation of this photo
is portrait, the red channel of top and bottom border will moved by 1.5 pixels.
is portrait, the red channel of top and bottom border will move by 1.5 pixels.
Pixels at the inner part the red channel will be moved less while the pixels
at the center of image will not be moved at all. (For a landscape image, the
left and right border will be moved by 1.5 pixels instead).

The LensX=1296/LensY=1944 is the image center, which is also the assumed optical
lens center. The lens center point can be moved around if you find one side needs
more correcting than the other side. Setting LensX=-1/LensY=-1 is also the same
as choosing the image center.

The interpolation parameter controls how the plug-in deals with fractional
pixels, for example, if the plug-in decides to move an image pixel by 0.8
pixel, 'Linear' and 'Cubic' settings will try to get a value by averaging
the surrounding pixels while 'None' will pick the nearest pixel (for this
example by moving 1 full pixel).

The 'Preview saturation' setting changes the saturation for the preview image.
This may help you spot CA problems. The setting does not have any effect on the
This helps you spot CA problems. This setting does not have any effect on the
final image produced by this filter.

Below is the 200% zoom for the resulting change using the above corrections.
Expand All @@ -88,29 +104,45 @@ Below is the 200% zoom for the resulting change using the above corrections.

In this example above we need to trade off between bottom right area (which
suffers from less CA) and the left area (the most CA).
If the image used is cropped, you can concentrate on fixing in the part of the
image that is actually used and ignore the rest. Just remember, a better result
can be expected if you correct CA before cropping.

Now that we know one side has more CA than the other, we can improve this image
further by moving the lens center towards the direction of less CA...

If we move the lens center right to approx LensX=1406, and increase Red=-2.0
due to the added distance on the left, this seems to resolve both left and right
sides. If you look at the bottom left corner, you will see some blue beginning
to appear, so if you change Blue=+0.6 this seems to fix that too....but we also
seem to have negative changes happening towards the wall near the roof....

...let's try again.... reset LensX=1296/LensY=1944 (or use LensX=-1/LensY=-1).

Before we start moving LensX/LensY, let us change saturation=100%, and let us
also try changing Red=-1.5 to Red=+1.5 instead, this is actually looking better.
...and seeing some blue let us also change Blue=-1.2, and we see better results
everywhere... and we also did not have to change LensX/LensY from image center.

For the majority of your pictures and images, you can assume the lens center is
also at the image center (unless you're working with a cropped image). If you want
to fix the [full sized original here](img-fix-ca/full-Wat_Pathum_Wanaram.jpg)
image further, then Fix-CA (version 4.0) now adds the ability to also move the
lens centerpoint (default is center of image).
Below you will see added variables LensX, LensY, allowing you to move the lens centerpoint to another location on the image.
also at the image center (unless you notice more left/right or up/down CA), or
if you are working with a cropped picture which may have the center elsewhere.

![](img-fix-ca/fix-ca-center.jpg)
Today's digital self-contained cameras are unlikely to have lateral problems
since they likely have built in software to correct for lateral problems, but you
can probably expect some amount of lateral CA for older analog type cameras.

Below is an example image using a poor man's zoom attached to a smartphone.
Even though a smartphone can correct an image for it's own lens, the poor man's
zoom attachment adds Lateral CA as well as having the lens center off to one side.
You may notice the pixel corrections seem like large values like 6.0, but this
applies to the (black) corners, and reduces down to about 3.0 around the edges of
where the lens image begins, eventually 0 pixel shift at lens center (658,1280).

![](img-fix-ca/ex-bran.jpg)
![](img-fix-ca/poorman-zoom.jpg)

To correct this, you may notice the pixel corrections seem like large values
like 6.0, but this applies to the (black) corners, and reduces down to about
3.0 around the edges of where the lens image begins, eventually a zero pixel
shift what seems to be a lens center of LensX=658/LensY=1280.

![](img-fix-ca/fix-ca-center.jpg)

Below is a Preview (off) of the leaves (showing blue). This can be corrected
using the Lateral CA settings shown above (can be seen with Preview on).

Expand All @@ -124,9 +156,7 @@ The [full sized original is here](img-fix-ca/full-branches.jpg).
In Directional Chromatic Aberration, the amount of CA is assumed to be the
same throughout the image. This happen, for example, when photographing
fish in an aquarium. Light travels through dense water and glass and bends
differently depending on the color and angle from the glass. This CA correction
mode was introduced in Fix-CA version 3.0.0. You can specify the amount of shift
for blue and red along both X and Y axis.
differently depending on the color and angle from the glass.

This example is a complete photo of a sleeping sea turtle.

Expand All @@ -150,35 +180,37 @@ The picture below shows (50% zoom) corrected image of the interested region.

![](img-fix-ca/Sea_turtle-fixed.jpg)

## Download and building Fix-CA
## Download and building GIMP3-Fix-CA

Fortunately, everything is in just one file. Just get the C source file.
To compile and install the plug-in, you need the development library
for Gimp. Usually it's in gimp-devel package in your distribution.
Use the command
```sh
gimptool-2.0 --install fix-ca.c
gimptool-3.0 --install fix-ca.c
```
will automatically compile and install into the local plug-in directory
of your account. For Windows users, if you wish to make the plug-in
of your home account. For Windows users, if you wish to make the plug-in
available to all users of the machine, use
```sh
gimptool-2.0 --install-admin fix-ca.c
gimptool-3.0 --install-admin fix-ca.c
```
instead. (use the Installation method below for other OSes). Type
```sh
gimptool-2.0 --help
gimptool-3.0 --help
```
for further help.

If Gimp is already running in your system, exit and restart Gimp for the new
plug-in to be detected. The following displays Fix-CA version 2.1.0 information
from the GIMP menu.
plug-in to be detected. The following displays GIMP3-Fix-CA information from
the GIMP menu.

![](plug-in-browser.png)

## Installation method

Developers and Distro installers will be more interested in this install method.
This method also includes local language support (for included languages).

Installing from Git master requires 2 preparatory steps:

Expand Down Expand Up @@ -222,6 +254,11 @@ make install

## Version History

GIMP3-Fix-CA
- 0.0 (May 15, 2024) First version.

GIMP2-Fix-CA
- 4.0 (February 29, 2024) Upgraded code to use GIMP-2.10 API. Now Gimp-Fix-CA works with RGB/RGBA with precisions of 8bit, 16bit, 32bit, or double for each color of R,G,B,A. Also added Lens X/Y center and a lens centerline in the preview window. Local Language support now included for the installable Gimp-Fix-CA. This version is bumped to 4.0 since it requires GIMP-2.10.xx, and also because non-interactive scripting also requires Lateral Lens X/Y positions (default=-1,-1)
- 3.0.4 (December 2, 2023) mostly edits around make system. Minimal mods to fix-ca.c code (which needs updating).
- 3.0.3 (October 8, 2022) autoconf/automake/configure/make added for building fix.ca
- 3.0.2 (December 22, 2007) Add the missing tile cache that speed up preview.
Expand All @@ -232,4 +269,6 @@ make install
- 1.0.0 (November 30, 2006) First version.


Note: The Original Web page content and pictures are copyrighted (c) 2006, 2007 by Kriang Lerdsuwanakij.
Note: The Original Web page content and pictures are copyrighted (c) 2006, 2007
by Kriang Lerdsuwanakij. New Added images and web page content added 2022..2024
by Jose Da Silva are under the same license as this GPL3+ project.
29 changes: 8 additions & 21 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
dnl Process this file with "autoreconf -i;automake" to produce a configure script.

# Copyright (C) 2022 by Joe Da Silva
# Copyright (C) 2024 by Joe Da Silva

AC_PREREQ([2.68])
#--------------------------------------------------------------------------
Expand All @@ -19,15 +19,13 @@ AC_PREREQ([2.68])
# fix_ca_major_version += 1;
# fix_ca_minor_version = 0;
#
m4_define([fix_ca_name], [gimp-fix-ca])
#m4_define([fix_ca_major_version], [3.0])
#m4_define([fix_ca_minor_version], [4])
m4_define([fix_ca_name], [gimp3-fix-ca])
m4_define([fix_ca_major_version], [0])
m4_define([fix_ca_minor_version], [0])
m4_define([fix_ca_version],[fix_ca_major_version.fix_ca_minor_version])
m4_define([fix_ca_package_name], [gimp-fix-ca])
m4_define([fix_ca_package_home], [https://github.com/JoesCat/gimp-fix-ca])
m4_define([fix_ca_package_email], [https://github.com/JoesCat/gimp-fix-ca/issues])
m4_define([fix_ca_package_name], [gimp3-fix-ca])
m4_define([fix_ca_package_home], [https://github.com/JoesCat/gimp3-fix-ca])
m4_define([fix_ca_package_email], [https://github.com/JoesCat/gimp3-fix-ca/issues])
#--------------------------------------------------------------------------
AC_INIT([fix_ca_name],[fix_ca_version],[fix_ca_package_email],
[fix_ca_package_name],[fix_ca_package_home])
Expand All @@ -54,7 +52,6 @@ AC_PROG_SED
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PATH_PROG([STRIP],[strip],[:])
#AC_PATH_PROG([GIMPTOOL],[gimptool-2.0],[:])
AC_PATH_PROG([GIMPTOOL],[gimptool-3.0],[:])
AC_PATH_PROG([MSGFMT],[msgfmt],[:])
AC_PATH_PROG([MSGINIT],[msginit],[:])
Expand Down Expand Up @@ -138,7 +135,6 @@ if test x"${have_gettext}" = xno; then
AC_SEARCH_LIBS([intl],[have_gettext=yes],[
AC_MSG_ERROR([ERROR: gettext() required! Please install libintl or GETTEXT Packages.])])
fi
#GETTEXT_PACKAGE=gimp20-fix-ca
GETTEXT_PACKAGE=gimp30-fix-ca
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext translation domain.])
Expand All @@ -159,20 +155,14 @@ AC_SUBST([ACLOCAL],["${ACLOCAL}"])
GIMP_CFLAGS=
GIMP_LIBS=
have_libgimp=no
#PKG_CHECK_MODULES([GIMP],[gimp-2.0 >= 2.10.0 gimpui-2.0 >= 2.10.0],[have_libgimp=yes])
PKG_CHECK_MODULES([GIMP],[gimp-3.0],[have_libgimp=yes])
PKG_CHECK_MODULES([GIMP],[gimp-3.0 gimpui-3.0],[have_libgimp=yes])
if test x"${have_libgimp}" != xyes; then
#AC_MSG_FAILURE([ERROR: Please install the developer version of libgimp2.],[1])
AC_MSG_FAILURE([ERROR: Please install the developer version of libgimp3.],[1])
fi
AC_SUBST(GIMP_CFLAGS)
#GIMP_LIBS="${GIMP_LIBS} -lgimpui-3.0"
#GIMP_LIBS="${GIMP_LIBS} -lgimpwidgets-3.0"
AC_SUBST(GIMP_LIBS)
#GIMP_LIBDIR=`${PKG_CONFIG} --variable=gimplibdir gimp-2.0`
GIMP_LIBDIR=`${PKG_CONFIG} --variable=gimplibdir gimp-3.0`
AC_SUBST(GIMP_LIBDIR)
#GIMP_DATADIR=`${PKG_CONFIG} --variable=gimpdatadir gimp-2.0`
GIMP_DATADIR=`${PKG_CONFIG} --variable=gimpdatadir gimp-3.0`
AC_SUBST(GIMP_DATADIR)

Expand All @@ -181,10 +171,8 @@ AM_CONDITIONAL([HAVEGIMPTOOL],[test "${GIMPTOOL}"x != x])
GTK_CFLAGS=
GTK_LIBS=
have_libgtk=no
#PKG_CHECK_MODULES([GTK],[gtk+-2.0],[have_libgtk=yes])
PKG_CHECK_MODULES([GTK],[gtk+-3.0],[have_libgtk=yes])
if test x"${have_libgtk}" != xyes; then
#AC_MSG_FAILURE([ERROR: Please install the developer version of libgtk+2.],[1])
AC_MSG_FAILURE([ERROR: Please install the developer version of libgtk+3.],[1])
fi
AC_SUBST(GTK_CFLAGS)
Expand Down Expand Up @@ -222,7 +210,6 @@ SNIPPET1='
ifeq ($(shell id -u),0)
bindir = $(GIMP_LIBDIR)/plug-ins/fix-ca
else
#bindir = $(libdir)/gimp/2.0/plug-ins/fix-ca
bindir = $(libdir)/gimp/2.99/plug-ins/fix-ca
endif
'
Expand Down Expand Up @@ -253,7 +240,7 @@ AH_BOTTOM([
AC_CONFIG_FILES([
Makefile
po/Makefile
rpm/gimp-fix-ca.spec
rpm/gimp3-fix-ca.spec
])
AC_OUTPUT
AC_MSG_NOTICE([
Expand All @@ -264,7 +251,7 @@ Configuration:
Build code location ${builddir}
docs root dir ${datarootdir}
bin plug-in dir ${GIMP_LIBDIR}/plug-ins/fix-ca
GIMP locale dir ${LOCALEDIR}
GIMP3 locale dir ${LOCALEDIR}
Use locale languages ${have_gettext}
Compiler ${CC}
CPPFLAGS ${CPPFLAGS}
Expand Down
Loading

0 comments on commit 04a6563

Please sign in to comment.