GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

gdalpansharpen.h
Go to the documentation of this file.
1 /******************************************************************************
2 * $Id: gdalpansharpen.h 33715 2016-03-13 08:52:06Z goatbar $
3 *
4 * Project: GDAL Pansharpening module
5 * Purpose: Prototypes, and definitions for pansharpening related work.
6 * Author: Even Rouault <even.rouault at spatialys.com>
7 *
8 ******************************************************************************
9 * Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 ****************************************************************************/
29
30 #ifndef GDALPANSHARPEN_H_INCLUDED
31 #define GDALPANSHARPEN_H_INCLUDED
32
33 #include "gdal.h"
34
35 CPL_C_START
36
47 typedef enum
48 {
50 GDAL_PSH_WEIGHTED_BROVEY
51 } GDALPansharpenAlg;
52
55 typedef struct
56 {
58 GDALPansharpenAlg ePansharpenAlg;
59
61 GDALRIOResampleAlg eResampleAlg;
62
64 int nBitDepth;
65
67 int nWeightCount;
68
70 double *padfWeights;
71
73 GDALRasterBandH hPanchroBand;
74
76 int nInputSpectralBands;
77
84 GDALRasterBandH *pahInputSpectralBands;
85
87 int nOutPansharpenedBands;
88
90 int *panOutPansharpenedBands;
91
93 int bHasNoData;
94
97 double dfNoData;
98
101 int nThreads;
102
103 double dfMSShiftX;
104 double dfMSShiftY;
105
106 } GDALPansharpenOptions;
107
108
109 GDALPansharpenOptions CPL_DLL * GDALCreatePansharpenOptions(void);
110 void CPL_DLL GDALDestroyPansharpenOptions( GDALPansharpenOptions * );
111 GDALPansharpenOptions CPL_DLL * GDALClonePansharpenOptions(
112 const GDALPansharpenOptions* psOptions);
113
115 typedef void* GDALPansharpenOperationH;
116
117 GDALPansharpenOperationH CPL_DLL GDALCreatePansharpenOperation(const GDALPansharpenOptions* );
118 void CPL_DLL GDALDestroyPansharpenOperation( GDALPansharpenOperationH );
119 CPLErr CPL_DLL GDALPansharpenProcessRegion( GDALPansharpenOperationH hOperation,
120 int nXOff, int nYOff,
121 int nXSize, int nYSize,
122 void *pDataBuf,
123 GDALDataType eBufDataType);
124
125 CPL_C_END
126
127 #ifdef __cplusplus
128
129 #include <vector>
130 #include "gdal_priv.h"
131 #include "cpl_worker_thread_pool.h"
132
133 #ifdef DEBUG_TIMING
134 #include <sys/time.h>
135 #endif
136
137 class GDALPansharpenOperation;
138
139 typedef struct
140 {
141 GDALPansharpenOperation* poPansharpenOperation;
142 GDALDataType eWorkDataType;
143 GDALDataType eBufDataType;
144 const void* pPanBuffer;
145 const void* pUpsampledSpectralBuffer;
146 void* pDataBuf;
147 int nValues;
148 int nBandValues;
149 GUInt32 nMaxValue;
150
151 #ifdef DEBUG_TIMING
152 struct timeval* ptv;
153 #endif
154
155 CPLErr eErr;
156 } GDALPansharpenJob;
157
158 typedef struct
159 {
160 GDALDataset* poMEMDS;
161 int nXOff;
162 int nYOff;
163 int nXSize;
164 int nYSize;
165 double dfXOff;
166 double dfYOff;
167 double dfXSize;
168 double dfYSize;
169 void *pBuffer;
170 GDALDataType eDT;
171 int nBufXSize;
172 int nBufYSize;
173 int nBandCount;
174 GDALRIOResampleAlg eResampleAlg;
175 GSpacing nBandSpace;
176
177 #ifdef DEBUG_TIMING
178 struct timeval* ptv;
179 #endif
180 } GDALPansharpenResampleJob;
181
184 class GDALPansharpenOperation
185 {
186 GDALPansharpenOptions* psOptions;
187 std::vector<int> anInputBands;
188 std::vector<GDALDataset*> aVDS; // to destroy
189 std::vector<GDALRasterBand*> aMSBands; // original multispectral bands potentially warped into a VRT
190 int bPositiveWeights;
191 CPLWorkerThreadPool* poThreadPool;
192 int nKernelRadius;
193
194 static void PansharpenJobThreadFunc(void* pUserData);
195 static void PansharpenResampleJobThreadFunc(void* pUserData);
196
197 template<class WorkDataType, class OutDataType> void WeightedBroveyWithNoData(
198 const WorkDataType* pPanBuffer,
199 const WorkDataType* pUpsampledSpectralBuffer,
200 OutDataType* pDataBuf,
201 int nValues,
202 int nBandValues,
203 WorkDataType nMaxValue) const;
204 template<class WorkDataType, class OutDataType, int bHasBitDepth> void WeightedBrovey3(
205 const WorkDataType* pPanBuffer,
206 const WorkDataType* pUpsampledSpectralBuffer,
207 OutDataType* pDataBuf,
208 int nValues,
209 int nBandValues,
210 WorkDataType nMaxValue) const;
211 template<class WorkDataType, class OutDataType> void WeightedBrovey(
212 const WorkDataType* pPanBuffer,
213 const WorkDataType* pUpsampledSpectralBuffer,
214 OutDataType* pDataBuf,
215 int nValues,
216 int nBandValues,
217 WorkDataType nMaxValue) const;
218 template<class WorkDataType> CPLErr WeightedBrovey(
219 const WorkDataType* pPanBuffer,
220 const WorkDataType* pUpsampledSpectralBuffer,
221 void *pDataBuf,
222 GDALDataType eBufDataType,
223 int nValues,
224 int nBandValues,
225 WorkDataType nMaxValue) const;
226 template<class WorkDataType> CPLErr WeightedBrovey(
227 const WorkDataType* pPanBuffer,
228 const WorkDataType* pUpsampledSpectralBuffer,
229 void *pDataBuf,
230 GDALDataType eBufDataType,
231 int nValues,
232 int nBandValues) const;
233 void WeightedBroveyPositiveWeights(
234 const GUInt16* pPanBuffer,
235 const GUInt16* pUpsampledSpectralBuffer,
236 GUInt16* pDataBuf,
237 int nValues,
238 int nBandValues,
239 GUInt16 nMaxValue) const;
240
241 template<int NINPUT, int NOUTPUT> int WeightedBroveyPositiveWeightsInternal(
242 const GUInt16* pPanBuffer,
243 const GUInt16* pUpsampledSpectralBuffer,
244 GUInt16* pDataBuf,
245 int nValues,
246 int nBandValues,
247 GUInt16 nMaxValue) const;
248
249 CPLErr PansharpenChunk( GDALDataType eWorkDataType, GDALDataType eBufDataType,
250 const void* pPanBuffer,
251 const void* pUpsampledSpectralBuffer,
252 void* pDataBuf,
253 int nValues,
254 int nBandValues,
255 GUInt32 nMaxValue) const;
256 public:
257 GDALPansharpenOperation();
258 ~GDALPansharpenOperation();
259
260 CPLErr Initialize(const GDALPansharpenOptions* psOptions);
261 CPLErr ProcessRegion(int nXOff, int nYOff,
262 int nXSize, int nYSize,
263 void *pDataBuf,
264 GDALDataType eBufDataType);
265 GDALPansharpenOptions* GetOptions();
266 };
267
268 #endif /* __cplusplus */
269
270 #endif /* GDALPANSHARPEN_H_INCLUDED */
GDALDataType
GDALDataType
Definition: gdal.h:57
GDAL_PSH_WEIGHTED_BROVEY
Definition: gdalpansharpen.h:50
GDALCreatePansharpenOptions
GDALPansharpenOptions * GDALCreatePansharpenOptions(void)
Create pansharpening options.
Definition: gdalpansharpen.cpp:56
GDALPansharpenOptions::ePansharpenAlg
GDALPansharpenAlg ePansharpenAlg
Definition: gdalpansharpen.h:58
gdal_priv.h
C++ GDAL entry points.
GDALRIOResampleAlg
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:113
GDALPansharpenOptions::dfNoData
double dfNoData
NoData value of the panchromatic and spectral bands (only taken into account if bHasNoData = TRUE)...
Definition: gdalpansharpen.h:97
GDALPansharpenOptions::bHasNoData
int bHasNoData
Definition: gdalpansharpen.h:93
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:233
GDALPansharpenOperation
Pansharpening operation class.
Definition: gdalpansharpen.h:184
GDALPansharpenAlg
GDALPansharpenAlg
Pansharpening algorithms.
Definition: gdalpansharpen.h:47
GDALPansharpenProcessRegion
CPLErr GDALPansharpenProcessRegion(GDALPansharpenOperationH hOperation, int nXOff, int nYOff, int nXSize, int nYSize, void *pDataBuf, GDALDataType eBufDataType)
Executes a pansharpening operation on a rectangular region of the resulting dataset.
Definition: gdalpansharpen.cpp:1621
GDALPansharpenOptions::nWeightCount
int nWeightCount
Definition: gdalpansharpen.h:67
GDALPansharpenOperationH
void * GDALPansharpenOperationH
Definition: gdalpansharpen.h:115
GDALClonePansharpenOptions
GDALPansharpenOptions * GDALClonePansharpenOptions(const GDALPansharpenOptions *psOptions)
Clone pansharpening options.
Definition: gdalpansharpen.cpp:101
GDALPansharpenOptions::nThreads
int nThreads
Number of threads or -1 to mean ALL_CPUS.
Definition: gdalpansharpen.h:101
GDALPansharpenJob
Definition: gdalpansharpen.h:139
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:248
GDALPansharpenOptions::nBitDepth
int nBitDepth
Definition: gdalpansharpen.h:64
GDALPansharpenOperation::Initialize
CPLErr Initialize(const GDALPansharpenOptions *psOptions)
Initialize the pansharpening operation.
Definition: gdalpansharpen.cpp:185
gdal.h
Public (C callable) GDAL entry points.
GDALPansharpenOptions::nInputSpectralBands
int nInputSpectralBands
Definition: gdalpansharpen.h:76
GDALDestroyPansharpenOperation
void GDALDestroyPansharpenOperation(GDALPansharpenOperationH)
Destroy a pansharpening operation.
Definition: gdalpansharpen.cpp:1587
GDALPansharpenOperation::~GDALPansharpenOperation
~GDALPansharpenOperation()
Pansharpening operation destructor.
Definition: gdalpansharpen.cpp:167
GDALPansharpenOptions::panOutPansharpenedBands
int * panOutPansharpenedBands
Definition: gdalpansharpen.h:90
GDALPansharpenOptions::padfWeights
double * padfWeights
Definition: gdalpansharpen.h:70
GDALPansharpenOptions
Pansharpening options.
Definition: gdalpansharpen.h:55
GDALDestroyPansharpenOptions
void GDALDestroyPansharpenOptions(GDALPansharpenOptions *)
Destroy pansharpening options.
Definition: gdalpansharpen.cpp:77
GDALPansharpenOptions::pahInputSpectralBands
GDALRasterBandH * pahInputSpectralBands
Array of nInputSpectralBands input spectral bands.
Definition: gdalpansharpen.h:84
GDALPansharpenOperation::ProcessRegion
CPLErr ProcessRegion(int nXOff, int nYOff, int nXSize, int nYSize, void *pDataBuf, GDALDataType eBufDataType)
Executes a pansharpening operation on a rectangular region of the resulting dataset.
Definition: gdalpansharpen.cpp:943
GDALPansharpenResampleJob
Definition: gdalpansharpen.h:158
GDALPansharpenOperation::GDALPansharpenOperation
GDALPansharpenOperation()
Pansharpening operation constructor.
Definition: gdalpansharpen.cpp:152
cpl_worker_thread_pool.h
Class to manage a pool of worker threads.
CPLWorkerThreadPool
Definition: cpl_worker_thread_pool.h:72
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:296
GDALCreatePansharpenOperation
GDALPansharpenOperationH GDALCreatePansharpenOperation(const GDALPansharpenOptions *)
Instantiate a pansharpening operation.
Definition: gdalpansharpen.cpp:1566
GDALPansharpenOptions::hPanchroBand
GDALRasterBandH hPanchroBand
Definition: gdalpansharpen.h:73
GDALPansharpenOptions::eResampleAlg
GDALRIOResampleAlg eResampleAlg
Definition: gdalpansharpen.h:61
GDALPansharpenOptions::nOutPansharpenedBands
int nOutPansharpenedBands
Definition: gdalpansharpen.h:87

Generated for GDAL by 1.8.8.