您现在的位置是:首页 >技术交流 >GDAL读取Jpeg2000格式图像网站首页技术交流
GDAL读取Jpeg2000格式图像
JPEG-2000标准支持无损和有损压缩,并且支持单图像分量(如灰度图像)和多图像分量(如彩色图像)。除了基本的图像压缩功能外,还支持其他的功能:1)对图像进行按精度或者按分辨率来渐进显示。2)感兴趣编码,就是对不同的图像区域给予不同的精度。3)对图像的某个区域进行随机访问时,不用对整个码流进行解码。4)提供一种灵活的图像格式,这种格式能够分辨出那些是图像数据信息,那些是码流内部信息。5)具有较好的容错性。
以上提到的功能特性都不是遥感图像选择Jpeg2000格式的主要理由,主要原因是它能记录空间坐标系(CRS),本文简要介绍GDAL读取Jpeg2000格式图像的相关知识。
GDAL库中提供了多种读取Jpeg2000的驱动。GDAL库中提供的读取Jpeg2000的驱动有下面几个:
JPEG2000 — Implementation of the JPEG-2000 part 1
JP2ECW – ERDAS JPEG2000 (.jp2)
JP2OpenJPEG — JPEG2000 driver based on OpenJPEG library
JP2KAK – JPEG-2000 (based on Kakadu)
JPIPKAK - JPIP Streaming
其中最常见的是前两种方法。以上的所有的库默认编译都是没有的,都需要第三方库的支持。依赖库分别是libjasper库,ECW库、OpenJPEG、Kakadu、MrSID库(顺序可能有问题哈,本文只用过ECW库库)
如果你也是用的ECW库来实现对JP2K格式的支持,那么编译完依赖库以后,首先用GetDriverByName来获取驱动。
poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);
这里的pszFormat,根据你所选的依赖库来确定。
可能是一下三种:
JP2OpenJPEG (rwv): JPEG-2000 driver based on OpenJPEG librar
JPEG2000 (rwv): JPEG-2000 part 1 (ISO/IEC 15444-1)
JP2ECW (rov): ERDAS JPEG2000 (SDK 4.2)
本文的pszFormat取值为JP2ECW。获取到驱动后,读取方法就跟tif一样了。
附:GDAL支持的驱动格式列表
ECW (rov): ERDAS Compressed Wavelets (SDK 4.2)
JP2ECW (rov): ERDAS JPEG2000 (SDK 4.2)
HDF4 (ros): Hierarchical Data Format Release 4
HDF4Image (rw+): HDF4 Dataset
HDF5 (ros): Hierarchical Data Format Release 5
HDF5Image (ro): HDF5 Dataset
MG4Lidar (ro): MrSID Generation 4 / Lidar (.sid)
MrSID (rov): Multi-resolution Seamless Image Database (MrSID)
JP2MrSID (rov): MrSID JPEG2000
netCDF (rw+s): Network Common Data Format
GMT (rw): GMT NetCDF Grid Format
VRT (rw+v): Virtual Raster
GTiff (rw+vs): GeoTIFF
NITF (rw+vs): National Imagery Transmission Format
RPFTOC (rovs): Raster Product Format TOC format
ECRGTOC (rovs): ECRG TOC format
HFA (rw+v): Erdas Imagine Images (.img)
SAR_CEOS (rov): CEOS SAR Image
CEOS (rov): CEOS Image
JAXAPALSAR (rov): JAXA PALSAR Product Reader (Level 1.1/1.5)
GFF (rov): Ground-based SAR Applications Testbed File Format (.gff)
ELAS (rw+v): ELAS
AIG (rov): Arc/Info Binary Grid
AAIGrid (rwv): Arc/Info ASCII Grid
GRASSASCIIGrid (rov): GRASS ASCII Grid
SDTS (rov): SDTS Raster
DTED (rwv): DTED Elevation Raster
PNG (rwv): Portable Network Graphics
JPEG (rwv): JPEG JFIF
MEM (rw+): In Memory Raster
JDEM (rov): Japanese DEM (.mem)
GIF (rwv): Graphics Interchange Format (.gif)
BIGGIF (rov): Graphics Interchange Format (.gif)
ESAT (rov): Envisat Image Format
FITS (rw+): Flexible Image Transport System
BSB (rov): Maptech BSB Nautical Charts
XPM (rwv): X11 PixMap Format
BMP (rw+v): MS Windows Device Independent Bitmap
DIMAP (rov): SPOT DIMAP
AirSAR (ro): AirSAR Polarimetric Image
RS2 (ros): RadarSat 2 XML Product
PCIDSK (rw+v): PCIDSK Database File
PCRaster (rw): PCRaster Raster File
ILWIS (rw+v): ILWIS Raster Map
SGI (rw+): SGI Image File Format 1.0
SRTMHGT (rwv): SRTMHGT File Format
Leveller (rw+): Leveller heightfield
Terragen (rw+): Terragen heightfield
ISIS3 (rov): USGS Astrogeology ISIS cube (Version 3)
ISIS2 (rw+v): USGS Astrogeology ISIS cube (Version 2)
PDS (rov): NASA Planetary Data System
TIL (rov): EarthWatch .TIL
ERS (rw+v): ERMapper .ers Labelled
JP2OpenJPEG (rwv): JPEG-2000 driver based on OpenJPEG library
L1B (rovs): NOAA Polar Orbiter Level 1b Data Set
FIT (rwv): FIT Image
GRIB (rov): GRIdded Binary (.grb)
JPEG2000 (rwv): JPEG-2000 part 1 (ISO/IEC 15444-1)
RMF (rw+v): Raster Matrix Format
WCS (rovs): OGC Web Coverage Service
WMS (rwvs): OGC Web Map Service
MSGN (ro): EUMETSAT Archive native (.nat)
RST (rw+v): Idrisi Raster A.1
INGR (rw+v): Intergraph Raster
GSAG (rwv): Golden Software ASCII Grid (.grd)
GSBG (rw+v): Golden Software Binary Grid (.grd)
GS7BG (rw+v): Golden Software 7 Binary Grid (.grd)
COSAR (ro): COSAR Annotated Binary Matrix (TerraSAR-X)
TSX (rov): TerraSAR-X Product
COASP (ro): DRDC COASP SAR Processor Raster
R (rwv): R Object Data Store
MAP (rov): OziExplorer .MAP
PNM (rw+v): Portable Pixmap Format (netpbm)
DOQ1 (rov): USGS DOQ (Old Style)
DOQ2 (rov): USGS DOQ (New Style)
ENVI (rw+v): ENVI .hdr Labelled
EHdr (rw+v): ESRI .hdr Labelled
GenBin (rov): Generic Binary (.hdr Labelled)
PAux (rw+): PCI .aux Labelled
MFF (rw+): Vexcel MFF Raster
MFF2 (rw+): Vexcel MFF2 (HKV) Raster
FujiBAS (ro): Fuji BAS Scanner Image
GSC (rov): GSC Geogrid
FAST (rov): EOSAT FAST Format
BT (rw+v): VTP .bt (Binary Terrain) 1.3 Format
LAN (rw+v): Erdas .LAN/.GIS
CPG (ro): Convair PolGASP
IDA (rw+): Image Data and Analysis
NDF (rov): NLAPS Data Format
EIR (rov): Erdas Imagine Raw
DIPEx (rov): DIPEx
LCP (rwv): FARSITE v.4 Landscape File (.lcp)
GTX (rw+v): NOAA Vertical Datum .GTX
LOSLAS (rov): NADCON .los/.las Datum Grid Shift
NTv2 (rw+vs): NTv2 Datum Grid Shift
CTable2 (rw+v): CTable2 Datum Grid Shift
ACE2 (rov): ACE2
SNODAS (rov): Snow Data Assimilation System
KRO (rw+v): KOLOR Raw
ARG (rwv): Azavea Raster Grid format
RIK (ro): Swedish Grid RIK (.rik)
USGSDEM (rwv): USGS Optional ASCII DEM (and CDED)
GXF (ro): GeoSoft Grid Exchange Format
HTTP (ro): HTTP Fetching Wrapper
NWT_GRD (rov): Northwood Numeric Grid Format .grd/.tab
NWT_GRC (rov): Northwood Classified Grid Format .grc/.tab
ADRG (rw+vs): ARC Digitized Raster Graphics
SRP (rovs): Standard Raster Product (ASRP/USRP)
BLX (rw): Magellan topo (.blx)
Rasterlite (rws): Rasterlite
SAGA (rw+v): SAGA GIS Binary Grid (.sdat)
KMLSUPEROVERLAY (rwv): Kml Super Overlay
XYZ (rwv): ASCII Gridded XYZ
HF2 (rwv): HF2/HFZ heightfield raster
PDF (rw): Geospatial PDF
OZI (rov): OziExplorer Image File
CTG (rov): USGS LULC Composite Theme Grid
E00GRID (rov): Arc/Info Export E00 GRID
ZMap (rwv): ZMap Plus Grid
NGSGEOID (rov): NOAA NGS Geoid Height Grids
MBTiles (rov): MBTiles
21At MBTiles (rov): 21At MBTiles
IRIS (rov): IRIS data (.PPI, .CAPPi etc)
WMTS (rwv): OGC Web Mab Tile Service
CNSDTF (rwv): China Geospatial Data Transfer Grid Format (.grd)
LANDSAT (rov): LANDSAT 7/8 GeoTiff with Metadata
参考:
编译支持JPEG2000压缩格式的GDAL(ECW库、OpenJPEG)_openjpeg opencl_鸿儒517的博客-CSDN博客