views:

290

answers:

3

Lets assume I have a bitmap with a square aspect and width of 2048 pixels.

In order to create a set of files need by Silverlight's DeepZoomImageTileSource I need to scale this bitmap to 1024 then to 512 then to 256 etc down to 1 pixel image.

There are two, I suspect naive, approaches:-

  1. For each image required scale the original full size image to the required size. However it seems excessive to be scaling the full image to the very small sizes.
  2. Having scaled from one level to the next discard the original image and scale each sucessive scaled image as the source of the next smaller image. However I suspect that this would generate images in the 256-64 range with poor fidelity than using option 1.

Note unlike with the Deep Zoom Composer this tool is expected to act in an on-demand fashion hence it needs to complete in a reasonable timeframe (tops 30 seconds). On the pluse side I'm only creating a single multiscale image not a pyramid of mutliple high-res images.

I am outside my comfort zone here, any graphics experts got any advice? Am I wrong about point 2? Is point 1 reasonably performant and I'm worrying about nothing? Option 3?

+1  A: 

About 1: This seems the best way. And it is not that excessive if you don't reload the source image each time.

About 2: Yes, you would looses (some) quality by scaling in steps.

I think 30 sec should be sufficient to scale a picture (a few times). Any optimization would be in the area of caching the results.

Henk Holterman
Thanks Henk, I think in the absence of any other strong opinions (and have done a little testing) I'll go with option 1 since its the simplest to implement.
AnthonyWJones
+1  A: 

What you are essentially trying to do is create MipMaps (see http://en.wikipedia.org/wiki/Mipmap). If you start out with a power of 2 square image, then scaling down the image to half the size then using the scaled down image to reduce its size by 2 again should give the same results as taking the original image and scaling it down by a factor of 4.

Each pixel in the half sized image will be the average of 4 pixels in the original image. Each pixel in the quater sized image will be the average of 16 pixels. It doesn't matter if you take the average of 16 pixels or the average of 4 pixels which where the average of 4 other pixels.

So I'd say you'd be fine with successively scaling images down as you mentioned in option 2. If you want to be sure then try both ways and compare the images.

Martin Sherburn
Thanks Martin. I see your point. I guess my attempt at making the question simple was a bit misleading. Actually the images will be typical sizes generated by scanners and digital cameras.
AnthonyWJones
+1  A: 

I realize this question is old, and maybe there's a reason you haven't done this, but if you get Microsoft's free Deep Zoom Composer, it comes with a DLL for making Deep Zooms, "DeepZoomTools.dll". It will create Deep Zoom compositions of a single image, or composites of many images. (The class ImageCreator does the heavy lifting of resizing images).

You should investigate the licensing implications if you're developing a commercial application, but reusing code is always better than writing it yourself.

Henry Jackson
I wasn't aware of that component. This project is currently working fine but I certainly will investigate whether swapping out my own code with this dll is a possibility. The fact that the tool itself is free and MS have actively encouraged devs to use it in their own apps leads me to believe that there should be no commercial issues with its use. Thanks for the heads up. ;)
AnthonyWJones