Image Analyzer - Introduction

 

Image Analyzer is a tool for digital artists and graphics programmers, showing the changing levels of colour across an image.

It could be considered a next generation colour picker, where a vertical or horizontal stripe across an image is analyzed, rather than the colour at a single point being selected.

Consider, for example, the following picture of the sky.

To produce this kind of image digitally, I would first fill my canvas with a graduated fill. The problem is how to set the curve of gradation to make it realistic?

In the analysis window the red, green and blue components are displayed. The blue is fairly linear, but the green and red are not. With a normal gradated fill, all colour values are graduated the same.

At this point, I can create a new bitmap from the original slice, or from the smoothed version. Individual red, green and blue colours are shown with a composite rgb in the colour bands at the bottom of the analyzer window.

Note the difference between the normal and smoothed bands.

Below the normal and smoothed bands are another two options. They represent Bezier and trigonometric curves fitted by eye to the colour lines. As I am interested only in the gradated sky, I can use either curve fitting technique.

 
Download
 


To download Ivencia Image Analyzer, click here.

 
Fitting a bezier curve
 
Bezier curves are fitted by first selecting the number of points from the menu. Each colour can be fit seperately with a different number of points, or all can be fit at once with the same number of points. In this case, I shall fit all (i.e. red green and blue) with only two points. From the menu, select Curve fitting | Fit bezier curves | All | 2. The default fit is shown below.

The points of the bezier curves are adjusted to fit the colour lines and extract only the sky without the clouds or bushes. The smooth gradation is shown in the bezier bars at the bottom of the page.

 
Fitting a trigonometric curve
 

A trigonometric fit is achieved by setting values in a separate window. To open the window, select Curve fitting | Show trig curve fitting window from the menu. the following window is displayed.

The values are adjusted using the up and down controls, or by typing values in the various boxes, until a satisfactory fit is achieved.

This image shows the values used to fit the red line. The equivalent equation is:

y = 0.00005x2 + 0.01x + 35

The hint of code in the text box at the bottom of the curve fit window is detailed below.

 
Exporting the image
 

From the menu, select File | Export.

In the export window, the size of the resulting image can be adjusted, and also the source of the image selected (normal, smoothed, bezier or trig fitting). Any changes made to the analyzer window - either by changing the smoothing, or adjusting the bezier handles or trigonometric prarameters - are immediately updated in the export window.

The image can be saved to a file, or to the clipboard for subsequent pasting into another application.

Here is the image saved to the clipboard and then pasted into Photoshop, ready for the creation of a better photorealism than ever before.

 
Code generation
 

Graphics programmers have the added benefit of code generation.

There are two code windows, one for trigonometric fitting, and the other for bezier fitting. For example, the trigonometric fit displayed above, produces the code:

struct RGB

{

    public byte R;

    public byte G;

    public byte B;

}

 

int length = 1704;

int x = 0;

double y,dx,dxx,dxxx;

RGB[] rgb = new RGB[length];

 

for (x=0; x<length; x++)

{

    // initialize the array

      rgb[x].R=0;

      rgb[x].G=0;

      rgb[x].B=0;

     

    // red

      dx = (double)x;

      dxx = dx * dx;

      y = 0

      y += 5E-05 * dxx;

      y += 0.01 * dx;

      y += 35

      if (y < 0) y = 0;

      else if (y > 255) y = 255;

      rgb[x].R = (byte)y;

 

    // green

      dx = (double)x;

      dxx = dx * dx;

      y = 0

      y += 3.5E-05 * dxx;

      y += 0.03 * dx;

      y += 86

      if (y < 0) y = 0;

      else if (y > 255) y = 255;

      rgb[x].G = (byte)y;

 

    // blue

      dx = (double)x;

      dxx = dx * dx;

      y = 0

      y += 1.5E-05 * dxx;

      y += 0.05 * dx;

      y += 140

      if (y < 0) y = 0;

      else if (y > 255) y = 255;

      rgb[x].B = (byte)y;

}

If this code is pasted into a function, it will produce a one dimensional RGB array. The array can then be copied to a bitmap.

The bezier code creates an array of points to hold the bezier points, and populates them as either a normalized array (0<X<=1, 0<Y<=255) or with the length or height of the image included.

NormalizedWith length

PointF[] Rpts = new PointF[4];

PointF[] Gpts = new PointF[4];

PointF[] Bpts = new PointF[4];

 

float offsetR = 35.73455;

float offsetG = 87;

float offsetB = 139;

 

//initialize arrays

int i = 0;

for (i = 0; i < Rpts.Length; i++)

    Rpts[i] = new PointF();

for (i = 0; i < Gpts.Length; i++)

    Gpts[i] = new PointF();

for (i = 0; i < Bpts.Length; i++)

    Bpts[i] = new PointF();

 

// Red

Rpts[0].X = 0.0f;

Rpts[0].Y = 0 + offsetR;

 

Rpts[1].X = 0.24f;

Rpts[1].Y = -2 + offsetR;

 

Rpts[2].X = 0.733f;

Rpts[2].Y = 68 + offsetR;

 

Rpts[3].X = 1.0f;

Rpts[3].Y = 148 + offsetR;

 

// Green

Gpts[0].X = 0.0f;

Gpts[0].Y = 0 + offsetG;

 

Gpts[1].X = 0.266f;

Gpts[1].Y = 1 + offsetG;

 

Gpts[2].X = 0.752f;

Gpts[2].Y = 90 + offsetG;

 

Gpts[3].X = 1.0f;

Gpts[3].Y = 153 + offsetG;

 

// Blue

Bpts[0].X = 0.0f;

Bpts[0].Y = 0 + offsetB;

 

Bpts[1].X = 0.217f;

Bpts[1].Y = 12 + offsetB;

 

Bpts[2].X = 0.919f;

Bpts[2].Y = 103 + offsetB;

 

Bpts[3].X = 1.0f;

Bpts[3].Y = 133 + offsetB;

float len = 1704; // enter required size here

 

PointF[] Rpts = new PointF[4];

PointF[] Gpts = new PointF[4];

PointF[] Bpts = new PointF[4];

 

float offsetR = 35.73455;

float offsetG = 87;

float offsetB = 139;

 

//initialize arrays

int i = 0;

for (i = 0; i < Rpts.Length; i++)

    Rpts[i] = new PointF();

for (i = 0; i < Gpts.Length; i++)

    Gpts[i] = new PointF();

for (i = 0; i < Bpts.Length; i++)

    Bpts[i] = new PointF();

 

// Red

Rpts[0].X = len * 0.0f;

Rpts[0].Y = 0 + offsetR;

 

Rpts[1].X = len * 0.24f;

Rpts[1].Y = -2 + offsetR;

 

Rpts[2].X = len * 0.733f;

Rpts[2].Y = 68 + offsetR;

 

Rpts[3].X = len * 1.0f;

Rpts[3].Y = 148 + offsetR;

 

// Green

Gpts[0].X = len * 0.0f;

Gpts[0].Y = 0 + offsetG;

 

Gpts[1].X = len * 0.266f;

Gpts[1].Y = 1 + offsetG;

 

Gpts[2].X = len * 0.752f;

Gpts[2].Y = 90 + offsetG;

 

Gpts[3].X = len * 1.0f;

Gpts[3].Y = 153 + offsetG;

 

// Blue

Bpts[0].X = len * 0.0f;

Bpts[0].Y = 0 + offsetB;

 

Bpts[1].X = len * 0.217f;

Bpts[1].Y = 12 + offsetB;

 

Bpts[2].X = len * 0.919f;

Bpts[2].Y = 103 + offsetB;

 

Bpts[3].X = len * 1.0f;

Bpts[3].Y = 133 + offsetB;

 
Price
 

Image Analyzer is free for the casual user. Commerical and broadcast users must purchase a licence. Each licence allows installation on one PC only.and costs GBP300. For bulk licensing, please email me.

 
How to buy
 

Click the button to buy with Paypal.

For corporate purchasing, send a purchase order by email to the address at the top of this page. If you wish to send a purchase order by post, please email me for my postal address.

Once your order is received, the installer will be emailed to you in a zip file.

 
Shopping basket