11-25-2018, 07:49 PM | #21 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
wwwmaze, btw, there's a typo in your YV12 version, it needs to be _1=eval_w*.5-1, in order to reset every scanline
I've merged the updated Gaussian kernel into my newer blur, here it is: Code:
// Blur (Gaussian) //@param1:sigma_parm 'Sigma' 10 0.5 100 25 0.1 //@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01 //@param4:want_l 'leftward' 1 0 1 0 1 //@param5:want_r 'rightward' 1 0 1 0 1 //@param6:want_u 'upward' 1 0 1 0 1 //@param7:want_d 'downward' 1 0 1 0 1 in=0; colorspace!='RGBA' ? colorspace='YV12'; input_info(in,project_w,project_h); w=project_w; h=project_h; function rot(new_ang, dest, blur) local(lw,lh,ang) ( gfx_dest=dest; ang = (new_ang+4-c_ang)&3; c_ang = new_ang&3; lw=(c_ang&1) ? h:w; lh=(c_ang&1) ? w:h; ang==0 ? gfx_blit(c_last,0, 0,0,lw,lh,0,0,lw,lh) : ang==1 ? gfx_deltablit(c_last, 0,0, lw,lh, 0, lw-1, 0, -1, 1, 0) : ang==2 ? gfx_deltablit(c_last, 0,0, lw,lh, lw-1,lh-1, -1, 0, 0, -1): ang==3 ? gfx_deltablit(c_last, 0,0, lw,lh, lh-1,0, 0, 1, -1, 0); blur ? ( sigma = sigma_parm * ((c_ang&1)?weight_mod:1/weight_mod); sigma > 0.5 ? ( q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330; b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3; b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3; b2 = -1.4281*q^2 - 1.26661*q^3; b3 = 0.422205*q^3; BB = 1-(b1+b2+b3)/b0; b1b0=b1/b0; b2b0=b2/b0; b3b0=b3/b0; eval_w = lw; gfx_evalrect(0,0,lw,lh, colorspace=='RGBA' ? " (_1 -= 1) < 0 ? ( _1=eval_w-1; _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b; ); r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r; g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g; b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b; " : " (_1 -= 1) < 0 ? ( _1=eval_w*.5-1; _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v; ); y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31; y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2; y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32; y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4; _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33; u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u; _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34; v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v; " ); ); ); c_last=dest; ); c_ang=0; c_last=in; max(sigma_parm/weight_mod,sigma_parm*weight_mod)>.5? ( want_l ? rot(2, -1, 1); want_d ? rot(3, img3 = gfx_img_resize(img3,h,w),1); want_u ? rot(1, img2 = gfx_img_resize(img2,h,w),1); want_r || c_last==-1 ? rot(0, c_last==-1 ? (img1 = gfx_img_resize(img1,w,h)) : -1,want_r); ); c_last != -1 ? rot(0, -1, 0); |
Thread Tools | |
Display Modes | |
|
|