TRANSFORM: Add Cubic B-Spline with Prefilter Algorithm #30411

Closed
opened 2012-03-01 08:07:20 +01:00 by Troy Sobotka · 20 comments

%%%Adds an extremely high quality scaling algorithm to the Transform scaling node implemented by Sergey.%%%

%%%Adds an extremely high quality scaling algorithm to the Transform scaling node implemented by Sergey.%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%Added an information wiki page for curious minds.%%%

%%%Added an information wiki page for curious minds.%%%
Author

%%%http://wiki.blender.org/index.php/User:Sobotka/Cubic_B-Spline_Scaling_Algorithm%%%

%%%http://wiki.blender.org/index.php/User:Sobotka/Cubic_B-Spline_Scaling_Algorithm%%%

%%%Correct me if I'm wrong, but I think line 237 of your patch should be if(ibuf && obuf && (fbuf || filter_type != 3)) instead of if(ibuf && obuf && fbuf) as fbuf is uninitialized if filter_type != 3.
%%%

%%%Correct me if I'm wrong, but I think line 237 of your patch should be if(ibuf && obuf && (fbuf || filter_type != 3)) instead of if(ibuf && obuf && fbuf) as fbuf is uninitialized if filter_type != 3. %%%
Author

%%%Quite correct. Good spot. I shifted allocation late in the game to being only if required.

I've also changed the coefficients array to use the outbuf. There isn't any overlap, and seeing as how it is single threaded, it is fine.

If it were threaded it would need to operate on the rows then columns per thread I'd think.

Thanks again for taking time to look.%%%

%%%Quite correct. Good spot. I shifted allocation late in the game to being only if required. I've also changed the coefficients array to use the outbuf. There isn't any overlap, and seeing as how it is single threaded, it is fine. If it were threaded it would need to operate on the rows then columns per thread I'd think. Thanks again for taking time to look.%%%
Author

%%%Attaching new patch.%%%

%%%Attaching new patch.%%%
Author

%%%Fixes typo. Patches named in YYMMDDHHMM.%%%

%%%Fixes typo. Patches named in YYMMDDHHMM.%%%

%%%Another thing : line 70 you do float *coeff = out->rect_float so, unless I've missed something, line 176 to 183 are unneeded (and if needed, a memcpy() is propably better than three nested for loops to copy data) .%%%

%%%Another thing : line 70 you do float *coeff = out->rect_float so, unless I've missed something, line 176 to 183 are unneeded (and if needed, a memcpy() is propably better than three nested for loops to copy data) .%%%
Author

%%%OBuf is most certainly assigned to rect_float of stackbuf, so the values are empty.

I'd like to use IMB_dupImBuf, but the way the code in the node_composite_transform.c works leaves it difficult as the ImBuf* is initialized and then the values are assigned.%%%

%%%OBuf is most certainly assigned to rect_float of stackbuf, so the values are empty. I'd like to use IMB_dupImBuf, but the way the code in the node_composite_transform.c works leaves it difficult as the ImBuf* is initialized and then the values are assigned.%%%
Author

%%%Using IMB_dupImBuf instead of a loop to copy the ImBuf. Also added cubic b-spline with prefilter to the Stabilize 2D node.%%%

%%%Using IMB_dupImBuf instead of a loop to copy the ImBuf. Also added cubic b-spline with prefilter to the Stabilize 2D node.%%%
Author

%%%Typo in (fbuf || filter_type != 3) wasn't showing Bilinear / Bicubic / Nearest results. %%%

%%%Typo in (fbuf || filter_type != 3) wasn't showing Bilinear / Bicubic / Nearest results. %%%
Author

%%%Ugh. Non square images are corrupted. Looking into the issue. Perhaps Julien you can spot the issue?%%%

%%%Ugh. Non square images are corrupted. Looking into the issue. Perhaps Julien you can spot the issue?%%%
Author

%%%Fixes for non square images and minor change to memcpy instead of a loop for copying to output buffer.

Optimization to follow.%%%

%%%Fixes for non square images and minor change to memcpy instead of a loop for copying to output buffer. Optimization to follow.%%%
Author

%%%About final patch methinks.

Refactoring of the code to support potentially threaded versions. Tidier as well.

Fixes the one pixel gutter in Bicubic scaling (may already be committed by Sergey) as the algorithm relies on the Bicubic pass.
%%%

%%%About final patch methinks. Refactoring of the code to support potentially threaded versions. Tidier as well. Fixes the one pixel gutter in Bicubic scaling (may already be committed by Sergey) as the algorithm relies on the Bicubic pass. %%%

%%%I'd really like to see this in trunk.
Especially since the Transform node is currently using the worst method possible (unprefiltered B-Spline is even more blurry than bilinear).

Minor remark about performance:
For threading, as I said, you'd need to tile the image (and add a 12px margin).
I think if you really need a faster prefilter, you could trivially gain 4x speedup by using SIMD to process the 4 channels in parallel.
Also I don't understand why you manually unrolled the loop on channels? It hurts the code clarity and genericity for no reason.
%%%

%%%I'd really like to see this in trunk. Especially since the Transform node is currently using the worst method possible (unprefiltered B-Spline is even more blurry than bilinear). Minor remark about performance: For threading, as I said, you'd need to tile the image (and add a 12px margin). I think if you really need a faster prefilter, you could trivially gain 4x speedup by using SIMD to process the 4 channels in parallel. Also I don't understand why you manually unrolled the loop on channels? It hurts the code clarity and genericity for no reason. %%%
Author

%%%Updated to new compositor. Full information is still available at http://wiki.blender.org/index.php/User:Sobotka/Cubic_B-Spline_Scaling_Algorithm.

Located the prefilter within imageprocess.c as opposed to a node operation to enable application of the approach system wide.%%%

%%%Updated to new compositor. Full information is still available at http://wiki.blender.org/index.php/User:Sobotka/Cubic_B-Spline_Scaling_Algorithm. Located the prefilter within imageprocess.c as opposed to a node operation to enable application of the approach system wide.%%%

%%%I'm glad you're not giving up on this.
I'm not sure why a change which improves quality without any work doesn't attract any more interest.
I'll hope you'll manage to lobby until this get in trunk ;)
Don't hesitate to contact me if I can be of any help.%%%

%%%I'm glad you're not giving up on this. I'm not sure why a change which improves quality without any work doesn't attract any more interest. I'll hope you'll manage to lobby until this get in trunk ;) Don't hesitate to contact me if I can be of any help.%%%

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#30411
No description provided.