Debanding Node #33930

Closed
opened 2013-01-19 14:22:23 +01:00 by Björn Sonnenschein · 7 comments

%%%This patch adds a new Node to the compositing system which will help to get rid of banding effects which are a problem when working with 8-bit images and videos.

Just for the record:
An unwanted posterization effect is what we call banding.
That means, we have a gradient that is so slight, that the value difference between neighboring pixels in a color space of higher bit depth (In the Blender pipeline we will internally deal with set-related color space) is so small that due to quantisation which is applied during the conversion to an other color space with low bitdepth (for example BT-709 YUV Space) the value of those pixels will be the same in the final image.
As consequence of that many 8 bit per channel images and videos suffer banding what is hardly noticeable if you view your material but will make big problems if you do intensive color manipulation with the compositor. You will see that color steps appear on flat image areas.

So what the node tries to do is:

  • Find banding steps: A banding step is a very low value delta in a group of at least three pixels. If there are only two pixels with a value difference, they could be part of a correctly rendered slight gradient. We always have at least two pixels of theoretically the same value which form a platform and another pixel with a slightly different value that forms the step to the next banding platform.
    So we try to find all vertical or horizontal groups of at least three pixels that have low value delta.

  • Blur the banding: Because blender works with float precision, we may simply blur all areas that suffer banding. We must take care that we only use pixels as samples for blurring that are inside the banding area. So if we have a blurring radius of 10, but the area of banding is only 5 pixels, we have to set the blur radius to 5 dynamically.

  • The node does this operation for the RGB channels by default, but with the single channel switch active it will only calculate the first input plane and pass this to G and B planes. The purpose of this is if you want to filter seperate channels by using the seperate RGB, YUV or HSV nodes. This will allow to control the debanding process for every channel separately which is important because blender works in RGB space while most video and many image formats come in YUV. That means the banding is in fact in those channels and will not be corrected properly if you filter it like an RGB image. The feature also enables you to deal with chroma sampling patterns more accurately by splitting the image into YUV channels and work with scaling nodes for the color planes prior to the deband node.

I tried to comment the code well so that you can easily understand what I did, sorry for my basic english.

The benefits for blender are:

  • Either for CGI or real video shots, material of low bit depth may like-to-be converted to a higher depth. That open many compositing, color correction and grading possibilities that were not there for such material before.

  • If you are working with an 8-bit video for example, with the debanding node applied blender's post-process dithering for rendering will now also work because banded gradients are quasi converted to blender's float space.%%%

%%%This patch adds a new Node to the compositing system which will help to get rid of banding effects which are a problem when working with 8-bit images and videos. Just for the record: An unwanted posterization effect is what we call banding. That means, we have a gradient that is so slight, that the value difference between neighboring pixels in a color space of higher bit depth (In the Blender pipeline we will internally deal with set-related color space) is so small that due to quantisation which is applied during the conversion to an other color space with low bitdepth (for example BT-709 YUV Space) the value of those pixels will be the same in the final image. As consequence of that many 8 bit per channel images and videos suffer banding what is hardly noticeable if you view your material but will make big problems if you do intensive color manipulation with the compositor. You will see that color steps appear on flat image areas. So what the node tries to do is: - Find banding steps: A banding step is a very low value delta in a group of at least three pixels. If there are only two pixels with a value difference, they could be part of a correctly rendered slight gradient. We always have at least two pixels of theoretically the same value which form a platform and another pixel with a slightly different value that forms the step to the next banding platform. So we try to find all vertical or horizontal groups of at least three pixels that have low value delta. - Blur the banding: Because blender works with float precision, we may simply blur all areas that suffer banding. We must take care that we only use pixels as samples for blurring that are inside the banding area. So if we have a blurring radius of 10, but the area of banding is only 5 pixels, we have to set the blur radius to 5 dynamically. - The node does this operation for the RGB channels by default, but with the single channel switch active it will only calculate the first input plane and pass this to G and B planes. The purpose of this is if you want to filter seperate channels by using the seperate RGB, YUV or HSV nodes. This will allow to control the debanding process for every channel separately which is important because blender works in RGB space while most video and many image formats come in YUV. That means the banding is in fact in those channels and will not be corrected properly if you filter it like an RGB image. The feature also enables you to deal with chroma sampling patterns more accurately by splitting the image into YUV channels and work with scaling nodes for the color planes prior to the deband node. I tried to comment the code well so that you can easily understand what I did, sorry for my basic english. The benefits for blender are: - Either for CGI or real video shots, material of low bit depth may like-to-be converted to a higher depth. That open many compositing, color correction and grading possibilities that were not there for such material before. - If you are working with an 8-bit video for example, with the debanding node applied blender's post-process dithering for rendering will now also work because banded gradients are quasi converted to blender's float space.%%%

Changed status to: 'Open'

Changed status to: 'Open'

%%%Added new version, deband_patch_2.txt
Uploaded an outdated version by accident before, sorry for that.%%%

%%%Added new version, deband_patch_2.txt Uploaded an outdated version by accident before, sorry for that.%%%
Member

%%%Debanding is an intensive operation. Please use complex node type and direct access to the input buffer to get more speed.%%%

%%%Debanding is an intensive operation. Please use complex node type and direct access to the input buffer to get more speed.%%%

%%%Would this code be transportable to the Sequencer too? Now that the color tools have been ported from the compositor there can be color grading work performed there as well. Perhaps as a modifier?%%%

%%%Would this code be transportable to the Sequencer too? Now that the color tools have been ported from the compositor there can be color grading work performed there as well. Perhaps as a modifier?%%%

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.

Hi, thanks for your patch. We are undergoing a [Tracker Curfew ](https://code.blender.org/?p=3861) where we are automatically closing old patches. If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#33930
No description provided.