How to replicate the calculation of end image in PDN Fragment Blur? [Solved]

I’m having a issue with fragment blur, and I’m not seeing a very good solution to it. I made fragment blur for g’mic, but alpha images are not calculated correctly hence the adding unnecessary codes. So, other than that, the question is in the title.

Here’s the PDN result I would like to achieve

Reference Test
image

PDN Result
image

G’MIC Result of my version of G’MIC Fragment Blur
image

As I explained to another user yesterday, G’MIC doesn’t have any concept of the alpha. Opacity is just another channel. I suggest that you try experimenting with the alpha only. You should be getting approximately the same effect without the rest of the image if you are doing it correctly.

I actually may have the answer. What I plan to do is to recursively do the blending mode calculation taking into account of alpha. I can get the alpha channel to be the same as the PDN result, it’s the coloring that bothers me, but recursively calculating should do the trick. blend_alpha 100/n where n is number of images works for 4 color channel image and a empty layer before all of that. For CMYK, recursion would fix the issue.

Here, I achieved it -

image


Update: Found a code that works for any number of color channels though it assumes the last channel is “alpha”, and ranges are between 0-255

rv / 255 if {s#0!=s#1} v + error "Spectrum numbers must be the same" fi is={s} l[1] s c a[0-{$!-2}] c endl l[0] s c a[0-{$!-2}] c endl repeat 2 l[{$>*2+1}] repeat {$is-2} . done a c endl done f[2] "srcC=i#2;srcA=i#3;dstC=i#0;dstA=i#1;outA=srcA+dstA*(1-srcA);(!outA==0)?(srcC*srcA+dstC*dstA*(1-srcA))/outA:0" f[3] "srcA=i#3;dstA=i#1;srcA+dstA*(1-srcA)" to_gray[3] a[2,3] c k[2] * 255

Now I believe I can really do the fragment blur from pdn with more features and working well on alpha images and with CMYKA images.