View Full Version : Blurring/Deblurring with generalconvolution; what am I doing wrong?


Katie Boundary
2nd October 2021, 22:26
I've been experimenting recently with a deinterlacing strategy that performs a vertical Gaussian blur, then resharpens by the same amount, like Blur(1.0).sharpen(1.0) but performed in only one direction. The goal is to blend orphaned fields with their closest matches, without changing the overall sharpness of the non-interlaced parts of the image and without needing to rely on dumb bad algorithms to figure out which parts of the image are interlaced and which aren't.

I've encountered three curiosities so far.

The first is that Blur(1.0).Sharpen(1.0), when applied to progressive content, yields a blurrier image than the original. Not by a lot, but it's noticeable.

The second is that, if I'm doing my math correctly and I understand how generalconvolution works, the correct amount of blurring and deblurring SHOULD be:

generalconvolution(0,"0 1 0 0 2 0 0 1 0")
generalconvolution(0,"0 -1 0 0 6 0 0 -1 0")

However, this produces even blurrier results than Blur(1.0).Sharpen(1.0). The results of Blur(1.0).Sharpen(1.0) are most accurately replicated by:

generalconvolution(0,"0 1 0 0 2 0 0 1 0")
generalconvolution(0,"0 -1 0 0 4 0 0 -1 0")

The third oddity is that, if I try making the deblurring step any sharper...

generalconvolution(0,"0 1 0 0 2 0 0 1 0")
generalconvolution(0,"0 -3 0 0 11 0 0 -3 0")

...the results (for progressive content) score worse on PSNR tests compared to the "-1, 4, -1" filter.



Any clarification on what's going on would be appreciated.

StainlessS
2nd October 2021, 23:06
but performed in only one direction
On the blur/Sharpen only

Blur

Blur(clip clip, float amount, bool MMX)
Blur(clip, float amountH, float amountV, bool MMX)

A 3×3 kernel blurring filter.


Sharpen(clip clip, float amount, bool MMX)
Sharpen(clip, float amountH, float amountV, bool MMX)

A 3×3 kernel sharpening filter; the inverse of Blur.

http://avisynth.nl/index.php/Blur

EDIT: Use eg Blur(0, 1.0) Sharpen(0, 1.0), vertical only.

Katie Boundary
3rd October 2021, 01:48
Well, that's definitely a useful shortcut! Thanks :)


On the other hand, I'm a bit disappointed that blending two fields from different frames together often produces results that look very different from blending the frames themselves together.

For example, expectation:

https://i.imgur.com/gvr3chk.png

Reality:

https://i.imgur.com/8064TA6.png

For that matter, even blurring alone, without the following sharpen step, doesn't completely eliminate the scanlines. How is THAT possible?

https://i.imgur.com/ynx9Gme.png