```
// Assumptions:
// x is in the range [0.0, 1.0], both inclusive
// f(x) is in the range [0.0, 1.0], both inclusive
// Every column value is defined by the lowest black pixel
public static double f(double x, Bitmap bmap)
{
double RetCode = 1.0; // no pixel, assume top most value 1.0
int positionX = (int)((double)bmap.Width * x + 0.5);
for(int positionY = 0; positionY < bmap.Height; positionY++)
{
Color pix = bmap.GetPixel( positionX, positionY );
if( pix.R == 0 )
{
RetCode = (double)positionY / (double)bmap.Height;
break;
}
}
return RetCode;
}
```

You can improve on the value extracted by also scanning the adjacent column and then linear interpolating by the fraction that the real positionX value is off from the integer part, but since this is a hand-drawn function curve, I think approximation by whole pixels is acceptable.

cheers,

Marco Bertschi

Well.. maybe there is a way to get text file from image?.. point =(1,1) - next point = (2,1) ..etc..

cheers,

Marco Bertschi

http://img254.imageshack.us/img254/1992/graphsample.png[^]

I need to get valus F(x) for example F(0.5) will be 0.32

—SA

For every car model and tuning there is individual wheel reaction function.

It looks like Need for speed have such kind of graps or they wrote some complex functions which is hard for my understanding.

—SA

—SA

I am with Sergey here, the question is why do you provide a hand drawn bitmap to define a F(x) function? Where do these bitmaps come from and are there other ways to have a user enter the coordinate pairs (x, F(x))? Are they visualization of some measurement?

(I can give you guidance how to extract your information from the bitmap, but first I want to know, if there are better ways to solve the whole problem.)

In this case I would recommend that you write a function that does linear approximation of parts of the curve (or some other approximation (e.g. quadratic) that you can model reasonably).

The function would look somehow along this line:

double F(double x)

{

double RetCode;

if(x < 0.2) {

RetCode = a1 * x + b1;

} else if (x < 0.6) {

RetCode = a2 * x + b2;

} else if (x < 0.8) {

RetCode = a3 * x + b3;

} else {

RetCode = a4 * x + b4;

}

return RetCode;

}

and find matching a1, b1, a2, b2, ...

Extracting the values form a hand-drawn pixel image is just not something you should ever reasonably consider. For example, some columns of your image had more than one pixel, what value would you assign in this case?