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
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