flat assembler
Message board for the users of flat assembler.
Index
> Main > color space conversion |
Author |
|
macomics 25 Mar 2022, 08:38
In the descriptions that I have available, the following interpretation of the Alpha channel is proposed in PNG format.
Code: MAXVAL := ( 1 << BITPERPIX ) - 1 BKGND.RED := ( ALPHA * IMAGE.RED + ( MAXVAL - ALPHA ) * BKGND.RED ) / MAXVAL BKGND.GREEN := ( ALPHA * IMAGE.GREEN + ( MAXVAL - ALPHA ) * BKGND.GREEN ) / MAXVAL BKGND.BLUE := ( ALPHA * IMAGE.BLUE + ( MAXVAL - ALPHA ) * BKGND.BLUE ) / MAXVAL |
|||
25 Mar 2022, 08:38 |
|
revolution 26 Mar 2022, 03:27
After converting RGB to grey scale, the alpha channel doesn't need any changes, it is still valid.
So you have grey+alpha. Then use the normal alpha merging code to place it onto the screen. If you choose to ignore the alpha channel then the edges of the image can appear "blocky". If you decide to use the alpha channel then a simple linear merge as suggested in the above code from macomics will work, but it isn't always what one may want. Another method is to use a gamma correction curve to get a better approximation matching the response of the human eye. This produces more pleasing results and has less noticeable artefacts around the edges. Edit: A common gamma correction value I've used a lot is this: Code: TO_GAMMA = dword 0.4545454545 ;1 / 2.2 TO_LINEAR = dword 2.2 |
|||
26 Mar 2022, 03:27 |
|
Ali.Z 26 Mar 2022, 16:02
for merging alpha with other components, I used lerp. (linear interpolation)
for gamma, I used different numbers from 2.224 down to 0.359 or 0.360. (calculated them on the fly because the image resolution was relatively small, 64x64, a look-up table is required for larger resolutions) as for color weighting I used what is provided in Rec. 601 standard. (a.k.a. CCIR 601 ----- although 601 is meant for SDTV and not for HDTV) (again didn't use a look-up table cuz small data) the attachment: top left cube = original image 50% alpha 2nd row, first cube, alpha got merged using lerp 2nd row, 2nd cube, lerp + CCIR 601 weighting 2nd row, last 4 cubes, lerp + CCIR 601 color weighting + gamma correction last row, CCIR 601 color weighting only (no gamma, no lerping) I'm still not pleased with the results, I still want to throw more arguments in the lerp formula and interpret alpha differently to get more variants. edit: Ali.Z wrote: last row, CCIR 601 color weighting only (no gamma, no lerping) alpha set to 255.
_________________ Asm For Wise Humans |
||||||||||
26 Mar 2022, 16:02 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.