PixelRange

Class Diagram


Description

The PixelRange Class defines the filter values of one color channel.

If you want to manipulate the W3C color "Lime", you have to find out the Value of the Color:

Hex -> #00FF00 = ARGB -> (255, 0, 255, 0)
Now, every number of this "255, 0, 255, 0" is one channel of the color. If you want to catch the second channel ("R" for red), you have to set up a PixelRange for this channel.

var redrange = new PixelRange(0, 50);
But why should we set two numbers? It is, because the colors of a picture, taken by a camera, are never perfect. Thats the reason why we have to set an upper and a lower bound of the channel.

You can check, if the color is between the lower and upper value with the "IsBetween" function.

Example

//Get a color (Lime = 255, 0, 255, 0)
Color limeColor = Color.Lime;

//Create a PixelRange for the red channel
PixelRange redRange = new PixelRange();

//Set Lower and Upper Value
redRange.Lower = 0;
redRange.Upper = 50;

//Check the R channel
bool doesMatch = redRange.IsBetween(limeColor.R);

Last edited Feb 1, 2011 at 2:02 PM by cansik, version 12

Comments

No comments yet.