Median Blur Node #18417

Closed
opened 2009-03-16 19:54:57 +01:00 by James Crosby · 8 comments

%%%The patch implements a median blur node, it's particularly useful for removing noise whilst maintaining sharp edges.

Only a 'square' blur aperture is implemented, and this is done by blurring first in the x direction, then in the y direction (in the same manner as most of the current blur filters work). I borrowed heavily from the existing blur node, however integrating the median blur there seemed a little cumbersome, so it is separate for the sake of simplicity.

A few things I'm unsure about:
Since only whole number values for the radius are used, other values are currently truncated. This seemed to be the behaviour of other filters, but doesn't seem to be the best thing to do.
My line endings (I think they're right, let me know ;)

%%%

%%%The patch implements a median blur node, it's particularly useful for removing noise whilst maintaining sharp edges. Only a 'square' blur aperture is implemented, and this is done by blurring first in the x direction, then in the y direction (in the same manner as most of the current blur filters work). I borrowed heavily from the existing blur node, however integrating the median blur there seemed a little cumbersome, so it is separate for the sake of simplicity. A few things I'm unsure about: Since only whole number values for the radius are used, other values are currently truncated. This seemed to be the behaviour of other filters, but doesn't seem to be the best thing to do. My line endings (I think they're right, let me know ;) %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Member

%%%Other blur nodes do two passes because they can be decomposed in such
way, and is faster. The result is the same (precission issues aside)
when done in one pass or two. Take the following small zone and
radius 3 median:

1 1 3
1 4 1
6 8 6

With one pass the result for center pixel is 3. With horizontal then
vertical, the result is 1.

I would not call it blur, just median filter, like many bibliography on
the topic. After all the purpose is denoising with minimal changes.
If you search a bit, you can find some methods that do a single pass and
are near constant time for any radius.
%%%

%%%Other blur nodes do two passes because they can be decomposed in such way, and is faster. The result is the same (precission issues aside) when done in one pass or two. Take the following small zone and radius 3 median: 1 1 3 1 4 1 6 8 6 With one pass the result for center pixel is 3. With horizontal then vertical, the result is 1. I would not call it blur, just median filter, like many bibliography on the topic. After all the purpose is denoising with minimal changes. If you search a bit, you can find some methods that do a single pass and are near constant time for any radius. %%%
Author

%%%Although in general, one would expect the two to be the same ;)

The best algorithm that seems to exist is the one described here: http://nomis80.org/ctmf.html
and an implementation licensed under GPLv3 is supplied; if that license is okay then I'll just plug it into Blender, but if I remember correctly, it isn't?

Also of note is that many of the very fast methods require enumerating the pixel values to create histograms – an approach that is not practical for floating point images like the ones passed between nodes.

Thanks for the input.
Back to the drawing board...

%%%

%%%Although in general, one would expect the two to be the same ;) The best algorithm that seems to exist is the one described here: http://nomis80.org/ctmf.html and an implementation licensed under GPLv3 is supplied; if that license is okay then I'll just plug it into Blender, but if I remember correctly, it isn't? Also of note is that many of the very fast methods require enumerating the pixel values to create histograms – an approach that is not practical for floating point images like the ones passed between nodes. Thanks for the input. Back to the drawing board... %%%
Author

%%%I've added a naive, but technically correct square median filter to the existing sequential one, also, the filter aperture is now rounded to the nearest pixel.

Still thinking about the faster methods: one relatively easy option would be to reduce the bit depth of the output image to 8 bits per channel, I don't know how acceptable that would be.
%%%

%%%I've added a naive, but technically correct square median filter to the existing sequential one, also, the filter aperture is now rounded to the nearest pixel. Still thinking about the faster methods: one relatively easy option would be to reduce the bit depth of the output image to 8 bits per channel, I don't know how acceptable that would be. %%%
Author

%%%median_17-3-2009-b.patch aligns the filter aperture correctly, and handles filter apertures with zero radius in one direction better.

Still thinking about faster methods: histogram / maintaining sorted group -type methods won't work with a varying filter radius: in this case I think the naive, grab-the-pixels, find the median, spit it out method is the only practical one.%%%

%%%median_17-3-2009-b.patch aligns the filter aperture correctly, and handles filter apertures with zero radius in one direction better. Still thinking about faster methods: histogram / maintaining sorted group -type methods won't work with a varying filter radius: in this case I think the naive, grab-the-pixels, find the median, spit it out method is the only practical one.%%%
Author

%%%median_18-3-2009.patch

  • Options for Circular, Cross or Square filter aperture.
  • Much faster, (though not much lower in algorithmic complexity): circular aperture of radius 5 (diameter 11) on 4 channel 1920x1080 takes around 15 seconds for me. (2.4 Ghz, 667Mhz RAM)

I'm going to shelve implementing a 'fast median' option for now.
%%%

%%%median_18-3-2009.patch - Options for Circular, Cross or Square filter aperture. - Much faster, (though not much lower in algorithmic complexity): circular aperture of radius 5 (diameter 11) on 4 channel 1920x1080 takes around 15 seconds for me. (2.4 Ghz, 667Mhz RAM) I'm going to shelve implementing a 'fast median' option for now. %%%
Member

%%%assigning to matt.%%%

%%%assigning to matt.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
Interest: X11
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#18417
No description provided.