RGB values = [ 0, 1, 2, 3,...,254,255]
255 - [ 0, 1, 2, 3,...,254,255] == [255,254,253,252,..., 1, 0] (1)
-1 value of signed byte is value 255 in unsigned byte.
-2 value of signed byte is value 254 in unsigned byte.
-3 value of signed byte is value 253 in unsigned byte.
...
I believe RGB value is treated as unsigned byte. Therefore:
0 - [ 0, 1, 2, 3,...,254,255] == [ 0,255,254,253,..., 2, 1] (2)
1 2
|
[255,254,253,252,..., 1, 0] (1) (correct one)
[ 0,255,254,253,..., 2, 1] (2) (incorrect)
|
compare the values in the 2 arrays, you can see why "Each RBG value is +1 compared to the correctly-inverted image." And there is one value that is greatly different from the correct value, which resulted in glichy areas, where the pixels has RGB values = (1,0,0) (0,1,0), (0,0,1), (1,1,0)...
For example:
- (1,1,0) ~ black after invert should be (254,254,255) ~ white. But the value 255 is 0 if you use "0 - color" method, which resulted in (255,255,0) -> yellow
- (1,0,0) ~ black after invert should be (254,255,255) ~ white. But the value 255 is 0 if you use "0 - color" method, which resulted in (255,0,0) -> red
to fix this, either +255 or -1 to the rgb values... which is the same as "255 - color" method ~.~
1 2 3 4 5 6 7 8 9
|
//same as 255 - blue...
blue = 0 - blue + 255;
green = 0 - green + 255;
red = 0 - red + 255;
//-1 - blue, which is also the same as 255 - blue...
blue = 0 - blue - 1;
green = 0 - green - 1;
red = 0 - red - 1;
|