dilevin / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
2 stars 10 forks source link

Desaturation Strange Zeroes #92

Closed JeremyXie123 closed 2 months ago

JeremyXie123 commented 2 months ago

For the desaturation step, aside from the +-1 discrepancies between the validation images and the ones I generate, I sometimes get a value of 0 when there shouldn't be.

For context, my rgba -> rgb agrees 1:1 with the validation rgb image. So it must be an issue with my desaturation implementation.

In the image below, I diff compared the image I produced (left) with the validation image (right).

Sometimes the value is zero when the true value is higher (136 in this example), but that's too big to be rounding error?

Considering all the values around it are correct, I'm confused.

If anyone has an idea what I might be doing wrong or encountered a similar issue, I'd appreciate the advice.

image

Zhecheng-Wang commented 2 months ago

"sometimes" usually implies memory related bug. My suspicion is uninitialized memory.

JeremyXie123 commented 2 months ago

"sometimes" usually implies memory related bug. My suspicion is uninitialized memory.

It was always for the same specific few pixels and I found the problem. I was not properly accounting for gray colors where the range was equal to 0 and that resulted in a division by 0.

Thanks, for the help!