I am currently facing an issue where I have to rewrite a python code into javascript which involves Image manipulation, mostly working with pixels.
I have a hard time wrapping my head around understanding the difference between the pixel values from Python vs the RGBA values of a pixel from Javascript.
What I mean by this, let's say we have this array of pixel values from python which I printed from the image:
[[0.43137255 0.43137255 0.43137255 ... 0.29411765 0.29019608 0.28235294]
[0.43529412 0.43137255 0.43137255 ... 0.27058824 0.25882353 0.24705882]
[0.43529412 0.43529412 0.43529412 ... 0.22352941 0.20784314 0.19607843]
...
[0.05882353 0.06666667 0.05882353 ... 0.03529412 0.04313725 0.05882353]
[0.05882353 0.05490196 0.03921569 ... 0.02745098 0.03529412 0.04705882]
[0.08627451 0.05490196 0.03921569 ... 0.05098039 0.09019608 0.05490196]]
As you can see, the pixels all have values closish to 0 (I believe it fluctuates between -1 and 1).
The same image in Javscript however prints a Uint8ClampedArray of (w * h * 4) values (RGBA) where every 4 steps is a pixel value.
The reason why I ask this, let's say I have a mathematical equation where I need to manipulate a pixel value based on some floats e.g.:
0.5 * (pixel_value_image1 + Math.cos(2 * 15) * pixel_value_image2 - Math.sin(2 * 15) * pixel_value_image3)
In Python, this value would result in something close to 0,00..... something. In Javascript however, the pixel value would either be approximated to 0 or 255, which is not desirable.
Any help would be greatly appreciated.