Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Instagram Valencia Filter Recipe - Mk1 (Nokia Imaging SDK)

From Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee -)
hamishwillee (Talk | contribs)
m (Hamishwillee - - Performance)
 
Line 118: Line 118:
 
! Device !! FPS (Frames Per Second)
 
! Device !! FPS (Frames Per Second)
 
|-
 
|-
| Lumia 1020 || ?-? FPS
+
| Lumia 1020 || 20-21 FPS
 
|-
 
|-
 
| - || -
 
| - || -

Latest revision as of 09:12, 28 February 2014

This recipe replicates Instagram's Valencia Filter using Nokia Imaging SDK inbuilt filters.

See Also
Article Metadata
Tested with
SDK: Windows Phone 8.0 SDK
Devices(s): Nokia Lumia 1020
Dependencies: Nokia Imaging SDK 1.0
Article
Created: hamishwillee (28 Feb 2014)
Last edited: hamishwillee (28 Feb 2014)

Contents

[edit] Introduction

The Instagram Valencia filter gives images a slight faded "1980's" appearance by adding a light brown and grey tint. This filter is used in about 5.04% of all photos shared on Instagram (source /filterfakers.com).

The recipe in this article shows how to recreate the Valencia filter by combining some of the 50+ inbuilt filters from the Nokia Imaging SDK. The recipe below is loosely based on a this youtube tutorial (no longer available).

The article includes the recipe source code, instructions on how it can be used and tested, performance measurements and a gallery.


[edit] Source code

The code for creating the effect, the source, renderer and target is described in #How to use the filter and Core concepts (Nokia Developer Library). The fragment below shows only the "recipe-specific" code for adding the filters to the List<IFilter>.

var filters = new List<IFilter>();
//Adjust colors
double ar = 1.752369270855186e-08;
double br = -1.835843575157521e-05;
double cr = 0.003760684854141;
double dr = 0.708921609107977;
double er = 30;
 
double ag = -1.055045968753709e-09;
double bg = 8.911970207324917e-07;
double cg = -2.590336356913679e-04;
double dg = 0.028503062912458;
double eg = 0.259107895292852;
 
double ab = 2.204671352703166e-09;
double bb = -1.303028437701711e-06;
double cb = 2.581991768409657e-04;
double db = -0.020690120745464;
double eb = 1.566757883591609;
double fb = 28;
 
Curve curve_red = new Curve(CurveInterpolation.Linear);
Curve curve_green = new Curve(CurveInterpolation.Linear);
Curve curve_blue = new Curve(CurveInterpolation.Linear);
 
for (int i = 1; i < 255; i++)
{
int yvalue = (int)(ar*Math.Pow(i, 4) + br*Math.Pow(i, 3) + cr*Math.Pow(i, 2) +dr*i + er);
curve_red.SetPoint(i, yvalue);
 
yvalue = (int)(ag*Math.Pow(i, 5) + bg*Math.Pow(i, 4) + cg*Math.Pow(i, 3) + dg*Math.Pow(i, 2) + eg*i);
curve_green.SetPoint(i, yvalue);
 
yvalue = (int)(ab * Math.Pow(i, 5) + bb * Math.Pow(i, 4) + cb * Math.Pow(i, 3) + db*Math.Pow(i, 2) + eb*i + fb);
curve_blue.SetPoint(i, yvalue);
}
 
filters.Add(new CurvesFilter(curve_red, curve_green, curve_blue));


[edit] How to use the filter

This recipe uses only filters based on IFilter. These are combined by simply adding them to an IFilter list, which is then passed to a FilterEffect along with the source. The code fragment below shows the general strategy (this is explained in more detail in Nokia Developer SDK - Core concepts).

var filters = new List<IFilter>();
//The recipe filters are added here
...
...
 
using (var source = new StreamImageSource(stream))
using (var filterEffect = new FilterEffect(source) { Filters = filters })
using (var renderer = new WriteableBitmapRenderer(filterEffect, writeableBitmap))
{
await renderer.RenderAsync();
}


[edit] Testing the filter

The easiest way to test the recipes is to add them to the Test Apps for Viewing Custom Filters (Nokia Imaging SDK) (a fork of the Real Time Filter Demo).


[edit] License

The code has been released with the standard MIT License.

[edit] Performance

This section lists the approximate frame rate range (in frames-per-second) obtained by using the recipe in the Test framework.

Device FPS (Frames Per Second)
Lumia 1020 20-21 FPS
- -

[edit] Gallery

This page was last modified on 28 February 2014, at 09:12.
189 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×