dilevin / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
1 stars 7 forks source link

Question about over operator #57

Open junior-stack opened 11 months ago

junior-stack commented 11 months ago

I am not sure if I should ask this question. Maybe just ignore this issue if it is not appropriate. I attempted both of the formulas in my implementation of over operator: image image

But, still I got the result picture as the following:

image

I checked my implementation and I followed carefully according to the formula in the wikipedia, but still do not know why it does not work on my side. Any suggestions on why it causes the problem in the picture.

Blucia commented 11 months ago

alpha for the equations are between 0 and 1

wenzhi-guo commented 11 months ago

Be careful with the ranges of the values. As mentioned above, the alpha channel needs to be normalized to between 0 and 1 in the above equations and scale back to 0 to 255 in the final output.

junior-stack commented 11 months ago

So does it mean alpha_0 need to multiply by 255.0 at the end?

wenzhi-guo commented 11 months ago

It should be in the same range as the input alpha values.