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. Thanks for all your past and future contributions.

Talk:HDR I - Implementing High Dynamic Range filters using Nokia Imaging SDK

From Wiki
Jump to: navigation, search


Hamishwillee - First review

Hi Sebastiano

Nice start. Some things really work well and some don't work quite as well. In terms of "work well". I really like the #HDR_Example with the sunglasses, the #Darkness filter is really cool (particularly the bottom set of images - the top reference is already pretty scary so not a good "contrast".

The color boost also impressed me - because it really shows how you can improve a fairly flat picture rather than just make it look colour boosted. I didn't have the same feeling with the Lomo filter - in this case if you compare HDR Lomo filter with normally exposed reference it isn't an improved image. It does make a smoother image than "plain lomo" as you've shown, but not sure people will actually like this effect as much - some people like Lomo "as it is".

For the blurred image (Koala) this is a pretty cool effect - it works because the chair is not particularly blurry and so you've effectively just blurred one object in the scene. I don't think he looks "glowing", I think he looks like a ghost. It would look even better if the chair wasn't blurred at all, but I guess you'd need to use edge detection of some kind for that effect and create a mask - an idea for another filter :-0

Anyway, for all of the above, I think the structure is slightly wrong - it should be:

  1. 1 line sentence on what the filter shows and its benefit
  2. Reference and Result images that show above benefit
  3. THEN any exposure images or other comparison

ie "state the benefit", show the benefit, then show where it came from. Sometimes the benefit will be different - the clock tower the benefit is improving the appearance using a more subtle colour boost (ie improving the original image). For others its improving the filter effect, not the reference image (hope this makes sense - in one case you're trying to improve the photo, the other you're trying to make cooler filter).

... walking my way though

  • Introduction - nice except the last sentence. I'll fix it if you can't during your review of these comments. The image used here is really good.
  • Image Alignment - the phase correlation does show white point but it is very small (I'd put "(see the white dot on the image below)" after you explain that).
    • Remember to attribute the image you used to Wikipedia
    • I would be tempted to skip the whole codeblock in the implementation section here and just have the prototype - the detail does not add anything. If you're hosting on gitorious or elsewhere you might link to the file. The other text you have explaining the function and why splitting into threads is not done is good.
  • HDR Engine section good
  • Blending Process - a few words before the code example about what it does
  • HDR Example section good but I would have as a one level higher heading "Pure HDR Example" or "Unfiltered HDR Example" to differentiate from all your other examples.
    • I would include the stuff just before this section in it (ie "I tested with Lumia 925, 920 and 820. 925 ha"
    • As in my early suggestion, "original" then "reference" image should be displayed before the other stuff used to create it.
  • Creating Filters - OK, so you need a better title. "Experiments in filtered-layer HDR" or similar.
    • YOu say: "The approach I followed was to leverage the HDR property to work with layers. I apply different filters at different layers, also all created filters first of all take advantage of HDR compared to standard shot process.". This is OK but you're trying to actually do 3 things - a)improve base images (ie not apply an obvious filter but make a picture which looks better than the original - like the clock tower example) b) "improve existing filters" (like the clock tower or lomo example) c) Create funky new features (like the dark one)
    • Other comments are "generic", as per the top.

I think this is really on to something: you've only got one "pure HDR example" and that is clear but subtle improvement. However there filter effects are genuinely new and innovative.

Does that make sense?



hamishwillee (talk) 10:31, 26 August 2013 (EEST)

Yan -

Hi. Really impressive (first time a see tone mapping make with blending)

If i understand, you compute only translation between pictures. Is it complicate to compute scale,angle and translation in same times?

I thinks you can use directly jpg file to manipulate 38Mp picture. To align picture you could use cropfilter if you want compensate only translation or my version if you want compensate scale, angle, translation. So you can create three EditingSession with {alignment filter, artistic filters} and use CreateBlendFilter to make the blending. (I thinks you can decompose your blending in two blending).

Normally, you can find lumia1020 picture with 3 exposure on the net(I'll try to find them).



yan_ (talk) 12:52, 26 August 2013 (EEST)

Galazzo - Rotation and Scaling

Hi Yan,

Yes I compute only translation but I worked on scaling and rotation and I have the code almost ready. The problem is that is still not finished in details but more I'm not so happy with performances.

The process is made by using Log Polar Transform beform Phase corralation. Translation give you the rotation and the magnitude ( manipulated ) the scale. Said that in a desktop environment is not a problem but in a mobile device that is already making a lot of stuff with FFT, alignment Nokia Filters etc etc increases waiting time.

I include multi threading but all the code should be ported in C++ to have acceptable performances. I plan to finish my article before deadline at after with calm start to switch to C++ and may be to create a library to import for an easier use.

If you are interesting I could add to article an explaination on how rotation scale works but is almost sure I will not be able to publish this feature in the library before deadline. May be Hamish could give a suggestion on that.

Let me know your thoughts.

About the blending process Hamish was right when suggested to add more information. I added more informations why I used my own method. To use the Nokia Imaging SDK's Blend filter is the ecquivalent of the naive method, but for more accurate results we need to blend in a smarter way.

The focus of article was also to explain better the basic behind HDR, anyway as I said the simple blending process, so using Nokia blending process could give good result and very good performances, so feel free to use it. but if you want to play with HDR I suggest to experiment new blending functions, you will discover a new worl if you are a bit passionate on imaging.

If you can provide me good 1020 samples I will play with it, but I hope to release my prototype so you also can experiment, but at time of writing interface is very ugly and really not feasible. The risk is that people think is the final application and judge it in the wrong way.

Let me know other suggestion or test you think would be interesting to experiment.



galazzo (talk) 13:15, 26 August 2013 (EEST)

Yan -

If you are interesting I could add to article an explaination on how rotation scale works but is almost sure I will not be able to publish this feature in the library before deadline. 

If you will not use it, i thinks it's not necessary. But maybe you can introduce it like a possible improvement.

but if you want to play with HDR I suggest to experiment new blending functions, you will discover a new worl if you are a bit passionate on imaging.

I know how HDR work ;). When i see your blending function, i thinks it can be done with two blends with very similar result. And so you can do all step (alignment, effect, blending) with Imaging SDK without temporary Image.

Your article is good and technically very interesting. It's just few ideas (good or bad) ;).

Good luck.

Ps 1 :I don't find images... just the articles Maybe you could contact author to have his pictures?

Ps 2 : to manipulate a writable bitmap you mustn't use WriteableBitmap.Pixels, WriteableBitmap.PixelWidth and WriteableBitmap.PixelHeight in the loop. They make unknown internal operation. You can use temporary value. You do it for PixelWidth and PixelHeiht but not for Pixels.

yan_ (talk) 15:21, 26 August 2013 (EEST)

Galazzo -

Hi Yan,

thanks for your suggestions and links.

Yes I agree with you I can use Imaging SDK for blending in fact I encourage their use. My blending function was created to allow sharpen operation and to have the full control for a more professional use, but sure you can have good result with a simple blending.

Can you explain better your Ps 2 ? You says I mustn't use WriteableBitmap.Pixels etc etc as they make unknown internal operation. In fact sometimes I have very strange behavior. Can you explain better this and what would be the best solution ?



galazzo (talk) 15:45, 26 August 2013 (EEST)

Yan -

Writeable properties are slow. I don't know why but they are slow. So, you must avoid to use them if possible.You can do for example :

var h = bmp.PixelHeight;
var w = bmp.PixelWidth;
var buffer = bmp.Pixels;//buffer is not copied, just referenced.
for (int i = 0; i <h; ++i)
for (int j = 0; j < w; ++j)
buffer [i * w + j] = ...

yan_ (talk) 16:05, 26 August 2013 (EEST)

Yan -

You can look this example.!2000&authkey=!ACy17lBwkAMphJE

It's an old test i make to try to manipulate WriteableBitmap with C# and C++.

yan_ (talk) 16:17, 26 August 2013 (EEST)

Galazzo -

Great !

Many thanks. I will look at them for sure.

Thanks again.


galazzo (talk) 16:28, 26 August 2013 (EEST)

Hamishwillee - Partial subedit - down to "darkness"

Hi Sebastiano

To make it easier to understand my points above, I've given this a partial subedit down to "darkness" section (because I won't have time to do this before judging on Monday). Note in the filters the structure - "what does the filter offer" followed by "the image showing the advantage", followed by the "how it was created": what this does for you is show how cool what you have done is FIRST. Call it marketing :-)

I've also gone through the other instructions improving the English and also putting mini introductions where it made sense. You should be able to copy this pattern.

IF you need to add more images - e.g. say you had better examples of "pure HDR" and "Glog" then I would pick your BEST image for each section top, then have other examples in a gallery - either at end of the respective section, or at the every end of the article.

Please check you're happy with the changes. Personally I am very happy that this is now a better showcase for the coolness you have produced!



hamishwillee (talk) 09:28, 30 August 2013 (EEST)

Galazzo - Improvements and new filters


I've added new filters and made improvements to the HDR algorithm. I plan to provide new examples images as I get new subjects that improves the effects showcase.

Suggestion for improvements or new filter are welcomed.


galazzo (talk) 02:44, 2 September 2013 (EEST)

Galazzo - Thanks

Thanks to Yan for his support helping me to improve performances :-)


galazzo (talk) 11:32, 3 September 2013 (EEST)

Mdrazek - Some questions

What those sliders in your app are doing? For sure, what should I do with result 'int[] buffer' after all? Generally I'm a newbie, so the question is: maybe, there is a chance to get more sources of your sample app for analyze? I'm trying this code and my HDR photos looks another than taken with your sample app. I would be a grateful.

Best regards and thanks anyway, Matthew.

mdrazek (talk) 15:22, 13 September 2013 (EEST)

Galazzo -

Hi Matthew,

Sliders eneable filters in the way explained in the article, applying them at each hdr layer.

Assunimg result is a WriteableBitamp with int[] buffer = Blend(... you shuld do domething like that:

buffer.CopyTo(result.Pixels, 0);

to save into phone library:

result.SaveJpeg(resultStream, CapturedImage.PixelWidth, CapturedImage.PixelHeight, 0, 85); where resultStream is a MemoryStream object.

I've already published the full code of functions and the DSP.cs library to download, may be is more useful if you share the code explainig better your troubles that could be useful for others.

You said that you are trying the code and results are not good as expected, but this not clear to me as if you don't know exactly what to do with int[] buffer didyou the rendering of HDR images ?

Please provide more details on what you implemented in order to allow me to undertand better and help you.

Finally thanks foryour interest.


galazzo (talk) 22:58, 15 September 2013 (EEST)

Igrali - Out of memory?

Amazing article, congrats on the Lumia 1020 :)

Is anyone else seeing an "Out of memory" exception during the blending process?

igrali (talk) 01:16, 17 September 2013 (EEST)

Hamishwillee - What device Igrali

Hi Igrali, best to let Sebastiano know what device you're seeing this on, and any other debug you can provide.

hamishwillee (talk) 03:58, 17 September 2013 (EEST)

Igrali - Out of memory?

Thanks Hamishwillee, I am using Lumia 920.

The exception happens usually around creating large WBs for tonemaps, here:

WriteableBitmap toneMap1 = new WriteableBitmap(CapturedImage.PixelWidth, CapturedImage.PixelHeight); WriteableBitmap toneMap2 = new WriteableBitmap(CapturedImage.PixelWidth, CapturedImage.PixelHeight); WriteableBitmap toneMap3 = new WriteableBitmap(CapturedImage.PixelWidth, CapturedImage.PixelHeight);

and goes like this:

InnerException = {System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

  at System.Windows.Media.Imaging.WriteableBitmap.AllocPixelBuffer()
  at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight)


Is there a project I can download to see how it's all connected, or does the article provide only code snippets?

I am probably missing something very obvious because I can see that the article code has been tested on Lumia 920 devices.

Any help appreciated, thanks!

igrali (talk) 23:04, 17 September 2013 (EEST)

Hamishwillee - There is a project

Hi Igrali

There is a prototype project linked - see the page Articlemetadata floating below the table-of-contents.



hamishwillee (talk) 04:36, 18 September 2013 (EEST)

Galazzo -

Hi Igrali,

add to your manifest file the following capabilities:

      <FunctionalCapability Name="ID_FUNCCAP_EXTEND_MEM"/>

In that way you ask to the system the permission to allow your App to use much memory than the standard allowed to Apps.

Let me know if you solve,


galazzo (talk) 19:29, 19 September 2013 (EEST)

Igrali - That solves it! :)

Thanks Sebastiano, this solved my problem. :)

Best regards

igrali (talk) 00:39, 20 September 2013 (EEST)

Hamishwillee - Update to latest imaging SDK?

Hi Sebastiano

According to the metadata for the article this is compatible with "Nokia Imaging SDK Beta 1" - can you update it to Nokia Imaging SDK 1.0?



hamishwillee (talk) 08:05, 10 February 2014 (EET)

Gombunan -


The latest SDK does not contain the EditingSession and FilterFactory class. How do I upgrade the Blend() function to support Nokia Imaging SDK v1.2.115.0?

gombunan (talk) 06:13, 16 June 2014 (EEST)