Log in

View Full Version : Bore: A Border Fixing Plugin


daoko
5th February 2024, 11:59
Repo: https://github.com/opusgang/bore

This is a border deringing plugin that uses linear regression without a constant term to adjust one line's brightness to another's on a per-frame basis. This effectively makes it very similar to edgefixer and bbmod. Compared to the former, its lack of a constant term makes more sense given how border ringing usually occurs, leading to a more stable adjustment. The latter also assumes a simple multiplication is sufficient; however, bore is capable of being less aggressive and allows for both spatial and color difference weighting in its weighted mode (bbmod is purely spatial).

Currently, there are five functions:

SinglePlane does simple linear regression between each line and the first clean line.
MultiPlane does the same with multiple linear regression using all three planes.
SinglePlaneLimited does this for each pixel individually using only the nearest pixels defined by ref_line_size.
SinglePlaneWeighted is SinglePlaneLimited with bilateral filter style weighting for distance and difference
. SinglePlaneDebug is the same as SinglePlane, but saves adjustment values to frame props instead of applying them.


Usage
core.bore.SinglePlane(clip clip, int left=0, int right=0, int top=0, int bottom=0, clip ignore_mask=None, int plane=0)
core.bore.MultiPlane(clip clip, int left=0, int right=0, int top=0, int bottom=0, clip ignore_mask=None, int plane=0)
core.bore.SinglePlaneLimited(clip clip, int left=0, int right=0, int top=0, int bottom=0, clip ignore_mask=None, int ref_line_size=100, int plane=0)
core.bore.SinglePlaneWeighted(clip clip, int left=0, int right=0, int top=0, int bottom=0, clip ignore_mask=None, float sigmaS=50.0, float sigmaR=0.5, float sigmaD=1.5, int ref_line_size=100, int plane=0)
core.bore.SinglePlaneDebug(clip clip, int left=0, int right=0, int top=0, int bottom=0, clip ignore_mask=None, int plane=0)

`clip`: 32-bit float clip.
`left = 0`, `right = 0`, `top = 0`, `bottom = 0`: number of lines from each border to adjust.
`ignore_mask = None`: 8-bit gray mask with pixels to avoid when calculating the adjustment. If more than one plane exists, only the first one is used, so it needs to match the to-be-adjusted plane's resolution.
`plane = 0`: Plane to adjust.
`sigmaS = 50, sigmaR = 0.5, sigmaD = 1.5`: SinglePlaneWeighted's smoothing parameters, same as a bilateral filter's, sigmaR is difference between pixels in same line, sigmaD is difference between adjustments compared to current pixel and its neighbor.
`ref_line_size = 100`: Reference line size for SinglePlaneLimited/Weighted. The actual size is `2 * ref_line_size + 1`.


Excluded pixels aren't processed and aren't used for calculating the adjustment. If there's enough interest, I might expand to allow for integer clips and/or multi-plane processing.

Results
bbmod vs bore.SinglePlaneWeighted:
https://slow.pics/c/4NLcaRxB

tormento
11th August 2024, 12:28
Would you please compile it for AVS+ too?

Selur
12th August 2024, 15:31
Totally missed this. :eek:
Seeing that the last Vapoursynth release was Feb 22, but the last changes are from Jun 8 a fresh Vapoursynth build would be nice too. :)
=> there a newer build in the actions :)
Bummer, to use FixBrightness you need libgsl-28.dll and the linked reference https://www.gnu.org/software/gsl/ only offers the source code.

daoko
22nd August 2024, 09:35
Would you please compile it for AVS+ too?
No, sorry. I'd very much like to see a PR for AVS support, though.

Totally missed this. :eek:
Seeing that the last Vapoursynth release was Feb 22, but the last changes are from Jun 8 a fresh Vapoursynth build would be nice too. :)
=> there a newer build in the actions :)
Bummer, to use FixBrightness you need libgsl-28.dll and the linked reference https://www.gnu.org/software/gsl/ only offers the source code.
Since it's a GNU project, you should be able to install GSL pretty easily with MinGW. I'm not a Windows user, though, so I can't help you there.

ChaosKing
22nd August 2024, 11:28
See githubs actions https://github.com/OpusGang/bore/actions

Selur
27th August 2024, 16:34
I can't get this working.
using:
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeringFilter/Bore/libbore.dll")
clip = core.bore.FixBrightness(clip, top=2, bottom=2, left=2, right=2)

I get:
AttributeError: There is no function named FixBrightness
so calling:
clip = core.text.Text(clip, text="\n".join(dir(core.bore)) )
Filteredne
SinglePlane
SinglePlaneDebug
SinglePlaneLimited
SinglePlaneWeighted
is listed.
I expected there to be 'FixBrightness' and 'Balance'.
here are the dlls I used: https://www.mediafire.com/file/s5d7c2chv3328xz/Bore.zip/file

Did I miss something?

Cu Selur

tormento
1st September 2024, 17:34
no, sorry. I'd very much like to see a pr for avs support, though.
A "pr"?

I can't get this working.
You succeeded?

Selur
1st September 2024, 17:52
You succeeded?
Stopped after:
If this is for some GUI, I'd suggest waiting a bit, since FixBrightness is gonna be removed soon and Balance is gonna be renamed.
see: https://github.com/OpusGang/bore/issues/5

Cu Selur

ChaosKing
1st September 2024, 22:46
A "pr"?


PR = Pull Request https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests