×
Namespaces

Variants
Actions
(Difference between revisions)

Creating and optimizing a custom effect for the Nokia Imaging SDK

From Nokia Developer Wiki
Jump to: navigation, search
SB Dev (Talk | contribs)
m (SB Dev - - Basic Implementation in C#)
SB Dev (Talk | contribs)
(SB Dev -)
Line 24: Line 24:
 
== Introduction ==
 
== Introduction ==
  
In this article we will first create a custom effect in C# that is able to apply a given convolution matrix to an Image. In the next step we will move that algorithm to native code using C++. We will proceed to create a checker that given two effects will compare their performance and check the equality of their results. Lastly we will explore common techniques used to transform an algorithm to take advantage of SIMD instructions. While illustrating the basic principle the final code makes no claim of being an optimal solution for the use case (especially as the application of many convolution matrices can be sped up a lot by taking advantage of the seperability of the result calculation (e.g. gaussian blur)).
+
In this article we will first create a custom effect in C# that is able to apply a given convolution matrix to an image. In the next step we will move that algorithm to native code using C++. We will proceed to create a checker that given two effects will compare their performance and check the equality of their results. Lastly we will explore common techniques used to transform an algorithm to take advantage of SIMD instructions. While illustrating the basic principle the final code makes no claim of being an optimal solution for the use case (especially as the processing of many convolution matrices can be sped up a lot by taking advantage of the seperability of the calculation).
 +
 
 +
Convolution matrices (often called kernels in imaging) can be used to achieve effects like blurring and sharpening and can also be used for edge detection. A detailed description of how this works conceptually can be found in the [http://en.wikipedia.org/wiki/Kernel_(image_processing) Wikipedia article on the topic].
  
 
== Basic Implementation in C# ==
 
== Basic Implementation in C# ==
Line 34: Line 36:
 
== Basic Implementation in C++ ==
 
== Basic Implementation in C++ ==
  
Creating a custom effect in C++ is a little more complicated than in C#. You can't directly inherit from a base class and only add the code required to transform the input to the output. Instead you have to make your WinRT component implement the interface {{icode|Nokia::Graphics::Imaging::ICustomEffect}}. In order to not have you implement everything yourself the resulting component is not an effect in it's own right but you have to wrap it inside a {{icode|Nokia.Graphics.Imaging.DelegatingEffect}} to execute it instead.
+
Creating a custom effect in C++ is a little more complicated than in C#. You can't directly inherit from a base class and only add the code required to transform the input to the output. Instead you have to make your WinRT component implement the interface {{icode|Nokia::Graphics::Imaging::ICustomEffect}}. In order to not have you implement everything yourself the resulting component is not an effect in it's own right but you have to wrap it inside a {{icode|Nokia.Graphics.Imaging.DelegatingEffect}} to execute it.
  
 
== Optimization using SIMD ==
 
== Optimization using SIMD ==

Revision as of 22:38, 19 November 2013

This article explains how to create a custom effect for the Nokia Imaging SDK, as well as optimizing it's performance by moving it to native code and providing guidance on how to transform an existing algorithm to take advantage of SIMD instructions like ARM NEON.

WP Metro Icon Graph1.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
Article Metadata
Tested with
SDK: Windows Phone 8.0 SDK
Compatibility
Platform(s):
Windows Phone 8
Article
Created: SB Dev (18 Nov 2013)
Last edited: SB Dev (19 Nov 2013)

Contents

Introduction

In this article we will first create a custom effect in C# that is able to apply a given convolution matrix to an image. In the next step we will move that algorithm to native code using C++. We will proceed to create a checker that given two effects will compare their performance and check the equality of their results. Lastly we will explore common techniques used to transform an algorithm to take advantage of SIMD instructions. While illustrating the basic principle the final code makes no claim of being an optimal solution for the use case (especially as the processing of many convolution matrices can be sped up a lot by taking advantage of the seperability of the calculation).

Convolution matrices (often called kernels in imaging) can be used to achieve effects like blurring and sharpening and can also be used for edge detection. A detailed description of how this works conceptually can be found in the Wikipedia article on the topic.

Basic Implementation in C#

A custom effect in C# can easily be created by making your effect class inherit from Nokia.Graphics.Imaging.CustomEffectBase. Only the OnProcess method needs to be implemented (more information on custom effects in C# can be found in the official documentation).

Filter Checker

Basic Implementation in C++

Creating a custom effect in C++ is a little more complicated than in C#. You can't directly inherit from a base class and only add the code required to transform the input to the output. Instead you have to make your WinRT component implement the interface Nokia::Graphics::Imaging::ICustomEffect. In order to not have you implement everything yourself the resulting component is not an effect in it's own right but you have to wrap it inside a Nokia.Graphics.Imaging.DelegatingEffect to execute it.

Optimization using SIMD

Loop Fusion

Loop Unrolling

Software Pipelining

Summary

Remove Category:Draft when the page is complete or near complete


The "platform categories" will be displayed here in preview only - Copy paste relevant categories into text here

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

754 page views in the last 30 days.
×