Author Topic: antialias ???  (Read 578 times)

daydreamer

  • Member
  • *****
  • Posts: 1553
  • building nextdoor
antialias ???
« on: July 19, 2020, 09:02:07 PM »
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
Code: [Select]
;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;
« Last Edit: July 20, 2020, 05:12:24 AM by daydreamer »
SIMD fan and macro fan
Happy new year 2021 that can only turn out to become better than worse 2020 :)

daydreamer

  • Member
  • *****
  • Posts: 1553
  • building nextdoor
Re: antialias ???
« Reply #1 on: July 25, 2020, 02:42:59 AM »
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
Code: [Select]
; 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;
SIMD fan and macro fan
Happy new year 2021 that can only turn out to become better than worse 2020 :)

Siekmanski

  • Member
  • *****
  • Posts: 2359
Re: antialias ???
« Reply #2 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.
Creative coders use backward thinking techniques as a strategy.

daydreamer

  • Member
  • *****
  • Posts: 1553
  • building nextdoor
Re: antialias ???
« Reply #3 on: July 25, 2020, 06:14:22 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
SIMD fan and macro fan
Happy new year 2021 that can only turn out to become better than worse 2020 :)