---
title: "支持无级缩放的360展示技术实现之二"
author: "chen4w"
date: "2015-12-07T12:24:57Z"
tags: []
categories: ["Web前端"]
slug: "360"
draft: false
lastmod: "2015-12-07T12:24:23Z"
id: 2262270
url: "https://chen4w.iteye.com/blog/2262270"
---

# 展品影像的采集及加工

本节对展品影像的采集及加工做个简单介绍。

## 影像采集

影像拍摄和采集的原理图如下：

![](http://dl2.iteye.com/upload/attachment/0113/5853/f2104e35-b1bf-3234-aa5e-cf12dcfa0f4a.png)  
 

主要硬件组成包括：步进电机驱动的转台、单反相机、用于控制单反相机快门与转台联动的PC，同时接收从单反相机获得的初始影像文件。

将拍摄对象的观察角度360度均分，转动转台每个角度拍摄一帧。从而获得观察对象的不同角度的若干帧（帧数越多，交互回放的转动越平滑，但所需要的文件存储容量越大）高清照片影像文件。采集阶段的工作遂告完成。

 

## 影像加工

即使对单帧影像而言，为了表现藏品细节，通常会使用较高的分辨率。即使采用jpg怎样的互联网格式进行压缩，其单个文件的尺寸达到10M左右也很常见。这样的图片在互联网上直接浏览，用户需要等待漫长的下载过程。即时完成下载缓存到用户浏览器端，一则会占用较大的系统内存，二则对于超高分辨率的影像，如果缺少缩放、平移和鹰眼这样的交互方式，用户的浏览体验将会比较糟糕。

针对此种场景，最常见的解决方案就是对影像进行金字塔式的切片预处理。经过处理的图片，配合浏览器端的组件，可以实现按需加载、无级缩放和平移。同时也支持浏览器端对已访问切片的缓存。

![](http://dl2.iteye.com/upload/attachment/0113/5855/42559ced-8dba-3990-9798-988e9963e448.png)  
 影像金字塔的方法在WebGIS获得广泛而且成熟的应用，它的原理如下：

指在同一的空间参照下，根据用户需要以不同分辨率进行存储与显示，形成分辨率由粗到细、数据量由小到大的金字塔结构。影像金字塔结构用于图像编码和渐进式图像传输，是一种典型的分层数据结构形式，适合于栅格数据和影像数据的多分辨率组织，也是一种栅格数据或影像数据的有损压缩方式。 如图所示：

从图中可以看出, 从金字塔的底层开始每四个相邻的像素经过重采样生成一个新的像素, 依此重复进行, 直到金字塔的顶层。重采样的方法一般有以下三种: 双线性插值、最临近像元法、三次卷积法。其中最临近像元法速度最快, 如果对图像的边缘要求不是很高的话,最适合使用该方法。三次卷积由于考虑的参考点数太多、运算较复杂等原因, 速度最慢, 但是重采样后图像的灰度效果较好。

每一层影像金字塔都有其分辨率的，比如说放大（无论是拉框放大、还是固定比例放大）、缩小、漫游（此操作不涉及到影像分辨率的改变）计算出进行该操作后所需的影像分辨率及在当前视图范围内会显示的地理坐标范围，然后根据这个分辨率去和已经建好的影像金字塔分辨率匹配，哪层影像金字塔的分辨率最接近就用哪层的图像来显示，并且根据操作后当前视图应该显示的范围，来求取在该层影像金字塔上，应该对应取哪几块，然后取出来画上去就可以了。

金字塔是一种能对栅格影像按逐级降低分辨率的拷贝方式存储的方法。通过选择一个与显示区域相似的分辨率，只需进行少量的查询和少量的计算，从而减少显示时间。

 

## 影像格式

下表列举了常见的符合上述原理的切片格式：

 

[Deep Zoom Composer](http://www.microsoft.com/en-us/download/details.aspx?id=24819)

desktop app for Windows

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Image Composite Editor](http://research.microsoft.com/en-us/um/redmond/projects/ice/)

panoramic image stitcher from Microsoft Research for the Windows desktop

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[DeepZoomTools.dll](http://blogs.msdn.com/b/expression/archive/2008/11/26/hello-deepzoomtools-dll-deep-zoom-image-tile-generation-made-easy.aspx)

.NET library, comes with Deep Zoom Composer

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[deepzoom.py](https://github.com/openzoom/deepzoom.py)

Python

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[deepzoom](http://search.cpan.org/~drrho/Graphics-DZI-0.05/script/deepzoom)

Perl utility

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[PHP Deep Zoom Tools](https://github.com/nfabre/deepzoom.php)

PHP

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Deepzoom](https://github.com/jeremytubbs/deepzoom)

PHP

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[DZT](https://github.com/dblock/dzt)

an image slicing library and tool written in Ruby

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[MapTiler](http://www.maptiler.org/)

desktop app for Windows, Mac, Linux

[TMS](http://openseadragon.github.io/examples/tilesource-tms/)

[VIPS](http://www.vips.ecs.soton.ac.uk/)

command line tool and library for a number of languages

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/) via the [dzsave](http://libvips.blogspot.co.uk/2013/03/making-deepzoom-zoomify-and-google-maps.html) feature

[Sharp](http://sharp.dimens.io/)

Node.js, uses VIPS

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[MagickSlicer](https://github.com/VoidVolker/MagickSlicer)

shell script (Linux/Mac)

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Gmap Uploader Tiler](https://github.com/mulka/tiler)

C++

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Node.js Deep Zoom Tools](https://github.com/openzoom/node-deepzoomtools)

Node.js, under construction

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Zoomable](http://zoomable.ca/)

service, offers embeds; no explicit API

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[ZoomHub](https://github.com/zoomhub/zoomhub)

service, under construction

[DZI](http://openseadragon.github.io/examples/tilesource-dzi/)

[Kakadu](http://kakadusoftware.com/)

C++ library to encode or decode JPEG 2000 images 

example of a batch convert script:[process\_jp2.py](https://github.com/DDMAL/diva.js/blob/master/source/processing/process_jp2.py)(Diva.js project)

[IIIF](http://openseadragon.github.io/examples/tilesource-iiif/) (requires a IIIF-compliant image server with JPEG 2000 support, like[Loris](https://github.com/pulibrary/loris); see also [iiif.io](http://iiif.io/) for more details)