How to transform the given function to be defined in another range?

I have the following weighting function: $$w(\rho) = k \cdot(\rho^\alpha)\cdot(1-\rho)^\beta,$$ where $$\rho$$ represents a pixel value expressed as a double, i.e., it ranges from $$0$$ to $$1$$, and $$1\le \alpha \le \beta$$.

How can I convert this function so that it shows a curve similar to the given one but works for pixel values expressed as uint8, i.e., ranging from $$0$$ to $$255$$?

In the following example of the function I take values $$\alpha = 1$$; $$\beta =6$$ and $$k =17.6$$. $w(\rho)$ for $$0\le \rho \le 1$$">

The simple answer is to divide your uint8 values by $$255$$ as a float. That gives you a value in $$[0,1]$$ That is almost certainly good enough for this purpose.
The subtlety comes because the float values may be equally distributed on $$[0,1]$$. The inverse transformation would be to multiply the floats by $$255$$. Since the float will never be $$1$$ you would never get a result of $$255$$. Even if you round, $$0$$ and $$255$$ will only get hit half as often as the other values. The improvement would be to multiply by $$256$$ and round down. Now if the floats are equally distributed, so are the uint8s. For the uint8 to float you could then divide by $$256$$.
• @MOHANTEJA I don't understand: for me it seems correct that a pixel value expressed as double is $6.376246841303954\cdot e^{-14}$ and expressed as uint8 is $0$. All doubles between $0$ and $1/256$ should be mapped to $0$ when expressed as uint8. – simonet Mar 13 at 21:21
• @MOHANTEJA: I am surprised that you can get a value of $6.37E-14$. That is extremely small. Most pixel values have only 16 or 24 bits, but this needs 44 to represent it. I suspect you are not interpreting the input correctly. If it is a correct input, it should be mapped to 0, as should any value less than $1/256$ – Ross Millikan Mar 13 at 23:33