Archive for February, 2008

Feb 25

Comparing photo Magnification algorithms used in photo software

If you have ever watched NCIS, CSI, numb3rs or any modern police related TV show you probably have seen them take a digital photo and enlarge it to reveal details. Because it is a TV show the photo magnification work perfectly and show wonderful details. Well this is fiction and in real world this is not going to append. However over the years, magnification algorithms have made serious progress so I thought it could be interesting to see how everyday softwares handle magnification.

The problem

The problem with photo magnification is the following: the computer has to infer information that does not exist. A photo as you probably already know is made of pixels (elementary points), hence an upscaled photo has more pixels that the original one. The question is which color theses new pixels should have ? Since there were not in the original photo, you have to guess. That exactly what does a magnification algorithm: It tries to guess what the new pixels should look like according to the original image. That is why TV show techniques are fiction: you can’t find information that wasn’t in the original set of pixels.
I have to precise that in this post I am talking about photo magnification, also know as interpolation, not video upscaling. Video interpolation algorithms can in some case combine multiples frames of the video to have a bigger pictures. (I save this for a future post).

How magnification work ?

The basic idea behind every magnification (interpolation) algorithm is to guess the value of the new pixel according to the real pixels that you find around it. To make it more efficient, many techniques have been tried such as bicubic, Lanczos, XinLin, DDL ones . If you want learn how an interpolation algorithm works read this excellent tutorial made by Sean. If you just want the basic idea, take a look at the diagram below taken from this tutorial:

Objectives

There is a bunch of comparison between extrapolation algorithm in research publication. This post is a little different because it has a pragmatic approach of the problem. It seek to answer the following question:

What result can I expect from my everyday software on a standard photo”

If you want an analysis of high end research algorithms that is all about numbers and variations take a look at this page.

Software tested

I choose three widely used photo software and a research soft wares to compare their results on average photos:

  1. Windows paint as baseline
  2. Gimp 2.4.4 which is the open source reference
  3. Photo shop CS3 which is the commercial reference
  4. SAR 3.4 which implement blending edge research algorithm

 

Methodolgy

In order to make the test the most objective possible, I did the following:

  • I took three photos with a resolution equal or above 400×400.
  • I downscale them to 200×200.
  • I upscale them to 400×400 using the different soft wares.
  • I made a visual comparison of each algorithm result for a relevant part of the photo.

Every photos during the process have been saved using the PNG algorithm to ensure that no distortion is introduced by a compression algorithm. Complete results and raw material are provided so you can judge by yourself, do the same, and even made more tests (I you do, I would be happy to publish them). Two of the three photos are human portrait because face are known to be hard to upscale and this is of course a very popular topic :) Please note that because the test was made on three images, this post cannot be considered as a reference benchmark (The methodology is correct but there is simply not enough data).

The photos

Photo 1 Evangeline Lilly aka Kate

The first photo is a portrait of Evangeline Lilly which play Kate in Lost. Here is the original (400×400) photo:

evangeline

The resulting downscaled photo (200×200)

evangeline

Photo 2 Matthew Fox aka Jake

I used a photo of Matthew Fox as the second photo, because unlike Evangeline, he have short hairs which should be easier to upscale. The original photo (400×400):

matthew-fox

The resulting downscaled photo (200×200)

matthew-fox

Photo 3 Nightwish Dark Passion play cover

As the last photo, I used the cover of the album Dark passion play because I wanted to see how upscaling algorithm handle light diffusion and text. The original photo (400×400):

NightwishDarkPassionPlay

The resulting downscaled photo (200×200)

NightwishDarkPassionPlay

The results

For each software, I tried various interpolation algorithms if possible. For the visual comparison I kept, the one that seems to be the better for each software. On the right of the comparison, you have the expected photo which is directly taken from the original file. Of course no algorithm is expected to be that perfect, but it allow to put things in perspective. In the visual comparison, I kept the recommended resize algorithm for Photo shop CS, the most advanced method (sic) for Gimp, and the back projected Jensen DDL for SAR. Complete results of extrapolation algorithm are visible in the photo galleries.

Result for Evangeline

compare-eva

As expected the SAR algorithm is clearly better. What is unexpected it that the paint algorithm is not so bad. You can found all the interpolations results below

Result for Matthew

compare-mat

Here the logic is respected, and there is a clear difference of quality, this is particular visible for the shirt and around the eyes. . You can found all the interpolations results below

Result for Nightwish

compare-night

Once again SAR is better, and this time the paint algorithm is clearly behind. This is obvious when you look at the word play. . You can found all the interpolations results below

Conclusion

As expected, the quality of the magnification is dependent of the software you use. Photo shop and Gimp are pretty close and SAR is way above. Note that SAR algorithms are way more slower than photoshop and GIMP algorithms because they performs a significant amount of computation. SAR is also much harder to use than the other products. If you dont understand the algorithms, it can give you hard time. If you want to see more comparison, AmericasWonderlands have made a very neat post about it. Feel free to send me your interpolation results so we will have a more significant corpus.

Feb 19

Nintendo DS game releases analysis

The Nintendo DS is one of the most successful console in the history. Hence it is not surprising that more than 2000 games where published. It is interesting to run a statistical analysis to see if we can find trends on DS game releases.

PHcover-thumb

Average Size

The first thing I was looking for was to see if the popular assumption that game size never cease to grow was true for the DS. The first thing I do was to compute the average size release after release:

average-size

Simple moving average

The average size trends shows that if the rom size was increasing at the beginning, it now tends to stabilize. However this increasing is not linear as the previous diagram let us thought. A simple moving average analysis reveals that the pattern is not monotonic:

mobile-average-size

weighted mobile average

Using a weighted mobile average allow to see that even if it is not monotonic there is still a real trends that game size on the average are getting bigger and bigger:

average-mobile-size

Theses graphs shows that the assumption that games are getting bigger and bigger over the time is true for the Nintendo DS on the average. However game size does not grow monotonically. Some game with small size are still released.

1096 b

Game releases by world region

The other assumption I wanted to verify was :

“there is much more game released in Japan that anywhere in the world.”

I wanted to quantify this notion of “more” so I broken down the rom release by region:

gamerepartition

This diagram confirm that the japan have way much more roms than Europe and USA. More surprisingly it shows that there is now more game released in Europe than in USA. This is quite unexpected and this trend is very recent (maybe a few months).

Game releases repartition in percentage

The current repartition show that 42% of the game releases were done in Japan. Its mean that more than 1 game of 4 are not released in Europe and in the USA.

repartitioncurrent

Accordingly the repartition in percentage over the time shows that except at the beginning the Japan as always get more releases. There is no sign that this tendency will be inverted so far.

gamerepartitionpercentage

Collusion

I was very surprised that the Europe start to get more release than the US. The fact that 1 game of 4 released in Japan is not available worldwide is not suprising. Finally the game average size let us hope that the DS is far from having reaching it maximum potential. The maximum size is 1024MB and in average we haven’t yet reach the half even when considering mobile average.

img10074000458