Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top