Click here to Skip to main content
15,901,505 members
Articles / Web Development / ASP.NET

"Hey! Is That My Car? How to Sharpen a QuickBird Satellite Image Using DotImage"

12 Nov 2007CPOL3 min read 70K   64   31   4
Atalasoft leverages their DotImage toolkit to manipulate color channels for the purpose of image enhancement, in this case satellite images. The article is a tutorial on image enhancement and it includes all source code and test images.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Image 1

This is a showcase review for our sponsors at The Code Project. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Because the bandwidth to a satellite is limited, sometimes they send their imagery as a high-resolution grayscale image and a low-resolution color image of the same area. Pan Sharpening is a class of GIS image processing techniques that are used to combine these two images into a single color image. The resulting image will appear to be at a higher resolution than the original color one.

The general idea is to transform the color image so that one channel of the image is substitutable by the high-resolution grayscale image. Then after the substitution, perform the reverse transforms, if necessary, to obtain a high-resolution color image.

To make sure we're on the same page so far, let's talk about color and channels. In an 8-bit grayscale image, each pixel is given a value that represents the "brightness" of that point in the image. 0 represents black and 255 represents white. A color image is made up of multiple channels, each can be thought of as being a single grayscale image. The usual way this is done is to have three channels, one for Red, Blue and Green. To determine the color of a pixel, the three channel values for that pixel are combined.

Using image-processing software or toolkits, such as DotImage, it's easy to operate on channels directly. Replacing, splitting, re-combining, and individually shifting channels are basic image-processing commands.

To do Pan Sharpening, the idea is to find a channel in the color image that conceptually is the same as the high-resolution grayscale image that you have. Unfortunately, neither Red, Green or Blue channels are appropriate for this. So, before doing the channel substitution it's necessary to transform the color space so that the channels have a different meaning, with one of them being analogous to the high-resolution grayscale image.

A common alternative to RGB is the Hue, Saturation and Lightness representation of color. The Lightness channel is actually a pretty close match to what we'd find in a grayscale image. So if we transform the image to HSL color representation, and then substitute the L channel with the grayscale image, and then transform the result back to RGB, we should end up with a color image that has a higher resolution.

Here is some C# code using DotImage. First you need to load the color and grayscale image:

AtalaImage color = new AtalaImage("atalasoft-color.jpg");
AtalaImage gray = new AtalaImage("atalasoft-gray.jpg");

You need to make sure the color image is the same size as the gray:

if (color.Size != gray.Size) {
    ImageCommand cmdResample = new ResampleCommand(gray.Size);
    ImageResults res = cmdResample.Apply(color);
    color = res.Image;

Next you need to translate the image to HSL. To do this, I have created a command called HslConvertCommand to handle converting the image between RGB and HSL.

HslConvertCommand toHslCmd = new HslConvertCommand(true);
color = toHslCmd.Apply(color).Image;

Substitute the Lightness channel

AtalaImage[] channels = {null, null, gray};
ImageCommand replaceLCmd = new ReplaceChannelCommand(channels);
ImageResults res = replaceLCmd.Apply(color);
color = res.Image;

And convert back to RGB:

HslConvertCommand toRGBcmd = new HslConvertCommand(false);
color = toRGBcmd.Apply(color).Image;

Here is the original Color image (a satellite photo of Atalasoft World Headquarters in Easthampton, MA)

Screenshot - image001.jpg

And here is the higher resolution grayscale image

Screenshot - image002.jpg

After running this code, here is the resulting higher resolution color image

Screenshot - image003.jpg

Attached to this article is a basic channel editor written using DotImage and some images so that you can play around. All of the source for the project is also included.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Atalasoft, Inc.
United States United States
Lou Franco is the Director of Engineering at Atalasoft, provider of the leading .NET Imaging SDK (DotImage) and the Document Viewer for SharePoint (Vizit).

Comments and Discussions

Questiondownload link broken? Pin
Member 466849421-Dec-11 23:19
Member 466849421-Dec-11 23:19 
AnswerRe: download link broken? Pin
David Groves5-Feb-13 9:30
David Groves5-Feb-13 9:30 
Generalimm.... Pin
Michael Sync23-Feb-08 7:53
Michael Sync23-Feb-08 7:53 
GeneralArtifacts Pin
Willi Deutschmann20-Dec-07 8:54
Willi Deutschmann20-Dec-07 8:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.