News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

antialias ???

Started by daydreamer, July 19, 2020, 09:02:07 PM

Previous topic - Next topic

daydreamer

I try to make a antialias code ,starting with 4 pixels calculate average, but replace the (a+b+c+d)/4,with some downsizing to get gray pixels and replace black pixels with gray to start with?what % white pixels should  grey be?
trying with SSE2 integer instructions
tests with pixel a=0,b= c= d=127
;a,b,c,d different pixels in a square 2x2
movd mm0, a ;start with get it right with 1pixel/register first
movd mm1, b
movd mm2, c
movd mm3, d
psrlw mm0, 2 ;downsizing before,otherwise endresult doesnt fit into byte
pand mm0, mask2
psrlw mm1, 2
pand mm1, mask2
psrlw mm2, 2
pand mm2, mask2
psrlw mm3, 2
pand mm3, mask2
paddusb mm0, mm1;add together 4pixels
paddusb mm2, mm3
paddusb mm0, mm2
; psrlw mm0, ?
; pand mm0,mask2
movd eax, mm0

mov result, eax;
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

maybe should cmp each pixel against threshold value,median or average so black/darkest pixels below threshold add pixel, grey,lightest pixels you sub pixel,grey
; a, b, c, d different pixels in a square 2x2
pxor mm7, mm7
movq mm7, unpt
movd mm0, a
movd mm1, b
movd mm2, c
movd mm3, d
movq mm6, mm3

paddd mm0, mm1
paddd mm2, mm3
paddd mm0, mm2
movq mm6, mm0
psrld mm0, 2;average /4
psrld mm6,3;grey1
movq mm5,mm6
movd a,mm6
    psrld mm6,1 ;darker grey


movd eax, mm0

mov result, eax;
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Siekmanski

You could change the aplha channel to a lower value for the surrounding pixels, its easier and no averaging calculations just set the alpha color.
Creative coders use backward thinking techniques as a strategy.

daydreamer

Quote from: Siekmanski on July 25, 2020, 04:36:44 AM
You could change the aplha channel to a lower value for the surrounding pixels, its easier and no averaging calculations just set the alpha color.
thanks
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding