VSE: replace Subsampled3x3 filter by a general Box filter #117584
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117584
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "aras_p/blender:vse_box_filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of overall "improve filtering situation" (#116980): replace Subsampled3x3 (added for blender 3.5 in
f210842a72
et al.) strip scaling filter with a general Box filter.Subsampled3x3 is really a Box filter ("average pixel values over NxM region"), hardcoded to 3x3 size. As such, it works pretty well when downscaling images by 3x on each axis. But starts to break down and introduce aliasing at other scaling factors. When scaling up or scaling down by less than 3x, using total of 9 samples is a bit of overkill and hurts performance.
So instead, calculate the amount of NxM samples needed by looking at scaling factors on X/Y axes. Note: use at least 2 samples on each axis, so that when rotation is present, the result edges will get some anti-aliasing, just like it was happening in previous filter implementation.
Notes
The (very recently added)
sequencer_render_filter.box
test is failing, as expected; the expected image needs to be updated with merge of this PR.Example images
Source: this perspective grid pattern image. The result images will be the same input, scaled down in VSE and then scaled up again with an adjustment layer using Nearest filtering:
Scaling that down by 3x using currently default Bilinear filtering produces a lot of aliasing, which the current Subsampled3x3 improves quite a bit. That is good so far:
However, at 4x downscaling, previous Subsampled3x3 vs the new Box:
At 15x downscaling, old vs new:
Or another case, this image:
Downscaling it exactly by 12x looks almost correct:
However downscaling it by 30x is complete nonsense!
The new Box filter, downscaling by 30x looks like this which is way more sensible:
5dcc8e4c74
toc25412142d
@blender-bot build
WIP: VSE: replace Subsampled3x3 filter by a general Box filterto VSE: replace Subsampled3x3 filter by a general Box filterHaving O(2) complexity could be good for the 3x3 size, but if we allow larger filter sizes we need to avoid it.
The box filter is separable, so you can apply it independently along the X and Y axis, significantly lowering the computational cost.
@Sergey I skipped on that so far since I thought that "hey, the upper count of total amount of samples done is bounded by the size of the source media", but you're right, I should at least try a separable filter. Will do!
@Sergey though now that I think about it, I'm not quite sure that separable approach would even work here at all. This is not convolution, this is resampling. Each NxM block of source pixels gets averaged into one destination pixel. As a result, all source pixels are read once, and they have to be. There's no way to rearrange or optimize anything; all the source pixels have to be sampled. If this was convolution (e.g. "box blur"), then sure, doing convolution in one direction and then in the other direction would save a lot of sampling, but this is not a convolution.
This is a good point. Somehow wasn't that obvious, and thought it is first doing some sort of LPF before resampling. Sorry for the confusion.