Jpegpixi

JPEG Pixel Interpolator

What is it?

‘Jpegpixi’ is short for ‘JPEG Pixel Interpolator’. The intent of the program is to interpolate pixels (single pixels, dots, stripes) in JPEG images. This is useful to correct images from a digital camera with CCD defects. For example, if one pixel is always bright green, this pixel can be interpolated with jpegpixi.

Jpegpixi is unique in that it tries to preserve the quality of the JPEG image as much as possible. Usual graphics programs decode JPEG images when they are loaded, and re-encode them when they are saved, which results in an overall loss of quality. Jpegpixi, on the other hand, only decodes the DCT blocks (typically 8×8, 16×8, or 16×16 pixel areas) which contain pixels to be interpolated, and when it re-encodes them, it uses exactly the same parameters with which the image has originally been encoded. These blocks are therefore only minimally disturbed, and other blocks remain pixel-by-pixel identical to the original image.

Jpegpixi is a command line utility. Its messages and the manual pages are available in four languages:

Jpegpixi is *-> Free Software, released under the GNU General Public License.

Download

To build the program, you need *-> version 6b of the JPEG library by the *-> Independent JPEG Group.

Debian packages are also available.

Bug Reporting

Bug reports should be mailed to <martin@zero-based.org>. Please include all relevant information. If jpegpixi fails to build, you should include the file config.log, which is created during configuration of the package. If jpegpixi crashes or behaves incorrectly at run time, please state the exact command you have used to invoke it, and include the original as well as the newly created image file.

Of course, you can also suggest new features you would like to have, or just tell me what you think of jpegpixi. :-)

Frequently Asked Questions

The following questions are answered in this section:

1. How do I find out the coordinates of a pixel?

Any graphics program should be able to help you with this. I personally use *-> ImageMagick's display program. The middle mouse button shows the coordinates in a zoomed window.

Alternatively, the jpeghotp program (which is part of the jpegpixi distribution) finds hot pixel blocks in an otherwise black JPEG image. To obtain an image suitable for jpeghotp, take a picture with your digital camera in total darkness or with covered lens.

2. Is jpegpixi idempotent?

Jpegpixi is idempotent (which means that if you run it twice with the same options, using the output of the first run as the input of the second, the image is not changed) for images compressed with a very high quality setting. For all other images, there is an inevitable quality loss in the blocks which contain the pixels to be interpolated. Of course, other blocks are not affected.

3. Does jpegpixi increase the file size?

Usually the file size is slightly decreased, which is not surprising, since the data can be better compressed after the interpolation. :-)

4. What interpolation methods does jpegpixi support?

It supports averaging adjacent pixels; linear, quadratic, and cubic interpolation in one dimension; and bilinear, biquadratic, and bicubic interpolation in two dimensions.

The command jpegpixi --help shows how to invoke a specific method.

5. Can jpegpixi read progressive JPEG files?

Yes, but it always writes baseline JPEG files.

Examples

Example 1

BeforeAfter
[example1-before.jpg]
example1-before.jpg (2362 B)
[example1-after.jpg]
example1-after.jpg (1720 B)

In this (somewhat artificial) example, the command

jpegpixi example1-before.jpg example1-after.jpg 22,22 67,22 22,67 67,67

has been used to remove the four red pixels. This has also decreased the file size by more than 27%.

Example 2

BeforeAfter
[example2-before.jpg]
example2-before.jpg (11660 B)
[example2-after.jpg]
example2-after.jpg (10567 B)

This (again artificial) example demonstrates the differences between 2-dimensional, horizontal 1-dimensional and vertical 1-dimensional interpolation. The command

jpegpixi -m3 example2-before.jpg example2-after.jpg 2:17,17,11 H:62,17,11 V:17,62,11 H:67,45,1,45 V:45,67,45,1

has been used here.

Example 3

BeforeAfter
[example3-before.jpg]
example3-before.jpg (2944 B)
[example3-after.jpg]
example3-after.jpg (2845 B)

This is (a part of) a picture I have actually taken with my digital camera. The green dot has been removed with the command:

jpegpixi example3-before.jpg example3-after.jpg 33,52,7