Lets assume I have a bitmap with a square aspect and width of 2048 pixels.
假设我有一个方形宽高比为2048像素的位图。
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.
为了通过Silverlight的DeepZoomImageTileSource创建一组需要的文件,我需要将此位图缩放到1024然后再缩放到512然后再缩放到256等,直到1像素图像。
There are two, I suspect naive, approaches:-
有两种,我怀疑天真,方法: -
- 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.
- 对于每个图像,需要将原始全尺寸图像缩放到所需大小。然而,将整个图像缩放到非常小的尺寸似乎过分。
- 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.
- 从一个级别缩放到下一个级别丢弃原始图像并将每个过度缩放的图像缩放为下一个较小图像的源。但是我怀疑这会产生256-64范围内的图像,保真度比使用选项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.
请注意,与Deep Zoom Composer不同,此工具有望以按需方式运行,因此需要在合理的时间范围内完成(最长30秒)。在这方面,我只创建一个单一的多尺度图像,而不是多层高分辨率图像的金字塔。
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?
我在这里的舒适区以外,任何图形专家都有任何建议吗?关于第2点我错了吗?第1点是合理的表现,我什么都不担心?选项3?
3 个解决方案
#1
1
About 1: This seems the best way. And it is not that excessive if you don't reload the source image each time.
大约1:这似乎是最好的方法。如果每次都不重新加载源图像,那就不算多了。
About 2: Yes, you would looses (some) quality by scaling in steps.
大约2:是的,通过逐步缩放,你会失去(某些)质量。
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.
我认为30秒应足以缩放图片(几次)。任何优化都将在缓存结果的领域。
#2
2
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.
您基本上要做的是创建MipMaps(请参阅http://en.wikipedia.org/wiki/Mipmap)。如果您从2平方图像的功率开始,然后将图像缩小到一半大小然后使用缩小的图像再次将其大小减小2应该给出与获取原始图像并将其缩小的相同结果因子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.
半尺寸图像中的每个像素将是原始图像中4个像素的平均值。四分之一大小的图像中的每个像素将是16个像素的平均值。如果你取16个像素的平均值或4个像素的平均值,其中4个其他像素的平均值无关紧要。
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.
所以我会说你可以按照你在选项2中提到的那样连续缩放图像。如果你想确定然后尝试两种方式并比较图像。
#3
2
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).
我意识到这个问题已经过时了,也许你有没有这样做的原因,但如果你得到微软免费的Deep Zoom Composer,它会附带一个用于制作Deep Zooms的DLL,“DeepZoomTools.dll”。它将创建单个图像的深度缩放合成,或许多图像的合成。 (ImageCreator类可以重复调整图像大小)。
You should investigate the licensing implications if you're developing a commercial application, but reusing code is always better than writing it yourself.
如果您正在开发商业应用程序,则应该调查许可影响,但重用代码总是比自己编写代码更好。
#1
1
About 1: This seems the best way. And it is not that excessive if you don't reload the source image each time.
大约1:这似乎是最好的方法。如果每次都不重新加载源图像,那就不算多了。
About 2: Yes, you would looses (some) quality by scaling in steps.
大约2:是的,通过逐步缩放,你会失去(某些)质量。
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.
我认为30秒应足以缩放图片(几次)。任何优化都将在缓存结果的领域。
#2
2
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.
您基本上要做的是创建MipMaps(请参阅http://en.wikipedia.org/wiki/Mipmap)。如果您从2平方图像的功率开始,然后将图像缩小到一半大小然后使用缩小的图像再次将其大小减小2应该给出与获取原始图像并将其缩小的相同结果因子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.
半尺寸图像中的每个像素将是原始图像中4个像素的平均值。四分之一大小的图像中的每个像素将是16个像素的平均值。如果你取16个像素的平均值或4个像素的平均值,其中4个其他像素的平均值无关紧要。
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.
所以我会说你可以按照你在选项2中提到的那样连续缩放图像。如果你想确定然后尝试两种方式并比较图像。
#3
2
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).
我意识到这个问题已经过时了,也许你有没有这样做的原因,但如果你得到微软免费的Deep Zoom Composer,它会附带一个用于制作Deep Zooms的DLL,“DeepZoomTools.dll”。它将创建单个图像的深度缩放合成,或许多图像的合成。 (ImageCreator类可以重复调整图像大小)。
You should investigate the licensing implications if you're developing a commercial application, but reusing code is always better than writing it yourself.
如果您正在开发商业应用程序,则应该调查许可影响,但重用代码总是比自己编写代码更好。