For a computer vision program, I have values between $0$ and $255$ that need to follow a cubic function ($y=x^3$) behavior so that :
- $f(255) = 255$
- $f(\frac{255}{2}) = 128$
- $f(0) = 0$
But I don't know how to find its equation. Thank you for your help.



A natural parameterIn addition to your own answer: a natural 4th condition is to fix the slope in the middle (that's the only thing you are allowing to change). This makes sense, because it defines the contrast of the nonlinear mapping. Using it this way, you can get through analytically.
Let's stretch everything to the unit square (divide $x$ and $y$ by $255$).
Start with a centered cubic curve (only odd terms allowed to keep the symmetry), it has one important parameter $a$ that sets the slope through the center: $$y(x)=x^3+ax$$
Make it go through $(1,1)$:
$$y(x)=\frac{x^3+ax}{1+a}$$
Now it goes from (-1,-1) to (1,1) and is symmetric around the center. Squeeze it into the box from (0,0) to (1,1) by scaling by factor of 1/2 and shifting by 1/2 in both axes:
$$y(x)=\frac12+\frac12\left(\frac{(2x-1)^3+a(2x-1)}{1+a}\right)$$
$2x-1$ is there so that it maps 0 to -1 and 1 to 1.
This is already a final solution (replace $x$ by $x/255$ and multiply result by $255$ to go back to byte values). This shows that most ugly terms come from expanding the powers, but actually, the function is much more simple and this is also how you should compute it if you are using floating point numerics (if using integers/bytes, then you must expand).
For different values of $a$ it has different slopes, but all go through desired points. A special case $a=0$ which has horizontal tangent is also interesting. Negative values of $a$ don't produce unique mappings (not one-to-one), so probably should be discarded, depending on what you want.
If you make $a$ very big, you converge towards linear mapping $y=x$.
An image showing a few samples: