That’s exactly what I did.
Here’s the current base for Fragment Blur (The code in rep_frblur uses every of those below, but that is not the base):
#@cli rep_shift_distance_angle_xy: _offset>0,_angle,_boundary_condition={ 0=None | 1=Neumann | 2=Periodic | 3=Mirror },_interpolation={ 0=nearest_neighbor | 1=linear }
#@cli : Offset images at angle and distance.
#@cli : (eq. to 'rep_sdaxy').\n
#@cli : _offset refers to the displacement of image.\n
#@cli : Default value: 'boundary_condition=3','interpolation=1'\n
#@cli : Author: Reptorian.
rep_shift_distance_angle_xy:
skip ${3=3},${4=1}
rad_ang={$2/180*pi}
shift {cos($rad_ang)*$1},{sin($rad_ang)*$1},0,0,$3,$4
#@cli rep_dupsdaxy: eq. to 'rep_duplicate_by_shift_distance_angle_xy'. : (+)
rep_dupsdaxy: rep_duplicate_by_shift_distance_angle_xy $*
#@cli rep_duplicate_by_shift_distance_angle_xy: duplicates_count>=2,_radius_offset>0,_offset_angle,_keep_original={ 0=remove_original | 1=keep_original },_boundary_condition={ 0=None | 1=Neumann | 2=Periodic | 3=Mirror },_interpolation={ 0=nearest_neighbor | 1=linear }
#@cli : Creates copies of image at a distance from original point.
#@cli : (eq. to 'rep_dupsdaxy').\n
#@cli : _radius_offset refers to the distance the duplicates are from the original image. Each circular duplicates are of the same distance. radius_offset can be in percentage form, or in integer form. When it is in percentage form, the length of each duplicates offset is equal to the percentage of diagonal of image.
#@cli : _offset_angle refers to the starting angle the original duplicate is at. The primary duplicate starts from the right.\n
#@cli : Default value: '_radius_offset={sqrt(w^2+h^2)*.05}','_offset_angle=0','_keep_original=0','_boundary_condition=0','_interpolation=1'\n
#@cli : Author: Reptorian.
rep_duplicate_by_shift_distance_angle_xy:
skip ${2={norm(w,h)*.05}},${3=0},${4=0},${5=1},${6=1}
if $1<2 v + error "Invalid duplicate numbers!" fi
aang={360/$1}
repeat $1 +rep_shift_distance_angle_xy[0] $2,{$>*$aang+$3},$5,$6 done if !$4 rm[0] fi
rep_frblur_1:
skip ${2={sqrt(w^2+h^2)*.05}},${3=0},${4=0},${5=1},${6=1}
sh 0,{s-2} sh.. {s} maxa={iM#-1} /. $maxa *.. . rm[-2,-1]
rep_duplicate_by_shift_distance_angle_xy $1,$2,$3,$4,{abs($5)},$6
add
sh 0,{s-2} sh.. {s} f.. i/(i0#-1?i0#-1:1) *. {$maxa/iM#-1} rm[-2,-1]
rep_frblur_2:
skip ${2={sqrt(w^2+h^2)*.05}},${3=0},${4=0},${5=1},${6=1}
rep_duplicate_by_shift_distance_angle_xy $1,$2,$3,$4,{$5!=0?abs($5):1},$6
ti=$!
add / $ti
frblur_1 is for images with alpha, and frblur_2 is for image without alpha.
The code is faster than your j approach, and the result is more in line with the PDN Fragment Blur. The problem becomes apparent when using images with much bigger dimension. Like as in 5000x3000 and then it becomes clear that it’s 10 times slower than the one in PDN.