GDAL
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 {
52 
55 typedef struct
56 {
59 
62 
64  int nBitDepth;
65 
68 
70  double *padfWeights;
71 
74 
77 
85 
88 
91 
94 
97  double dfNoData;
98 
101  int nThreads;
102 
103  double dfMSShiftX;
104  double dfMSShiftY;
105 
107 
108 
112  const GDALPansharpenOptions* psOptions);
113 
116 
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 
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;
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
181 
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:
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
Definition: gdal.h:57
Definition: gdalpansharpen.h:50
GDALPansharpenOptions * GDALCreatePansharpenOptions(void)
Create pansharpening options.
Definition: gdalpansharpen.cpp:56
GDALPansharpenAlg ePansharpenAlg
Definition: gdalpansharpen.h:58
C++ GDAL entry points.
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:113
double dfNoData
NoData value of the panchromatic and spectral bands (only taken into account if bHasNoData = TRUE)...
Definition: gdalpansharpen.h:97
int bHasNoData
Definition: gdalpansharpen.h:93
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:233
Pansharpening operation class.
Definition: gdalpansharpen.h:184
GDALPansharpenAlg
Pansharpening algorithms.
Definition: gdalpansharpen.h:47
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
int nWeightCount
Definition: gdalpansharpen.h:67
void * GDALPansharpenOperationH
Definition: gdalpansharpen.h:115
GDALPansharpenOptions * GDALClonePansharpenOptions(const GDALPansharpenOptions *psOptions)
Clone pansharpening options.
Definition: gdalpansharpen.cpp:101
int nThreads
Number of threads or -1 to mean ALL_CPUS.
Definition: gdalpansharpen.h:101
Definition: gdalpansharpen.h:139
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:248
int nBitDepth
Definition: gdalpansharpen.h:64
CPLErr Initialize(const GDALPansharpenOptions *psOptions)
Initialize the pansharpening operation.
Definition: gdalpansharpen.cpp:185
Public (C callable) GDAL entry points.
int nInputSpectralBands
Definition: gdalpansharpen.h:76
void GDALDestroyPansharpenOperation(GDALPansharpenOperationH)
Destroy a pansharpening operation.
Definition: gdalpansharpen.cpp:1587
~GDALPansharpenOperation()
Pansharpening operation destructor.
Definition: gdalpansharpen.cpp:167
int * panOutPansharpenedBands
Definition: gdalpansharpen.h:90
double * padfWeights
Definition: gdalpansharpen.h:70
Pansharpening options.
Definition: gdalpansharpen.h:55
void GDALDestroyPansharpenOptions(GDALPansharpenOptions *)
Destroy pansharpening options.
Definition: gdalpansharpen.cpp:77
GDALRasterBandH * pahInputSpectralBands
Array of nInputSpectralBands input spectral bands.
Definition: gdalpansharpen.h:84
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
Definition: gdalpansharpen.h:158
GDALPansharpenOperation()
Pansharpening operation constructor.
Definition: gdalpansharpen.cpp:152
Class to manage a pool of worker threads.
Definition: cpl_worker_thread_pool.h:72
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:296
GDALPansharpenOperationH GDALCreatePansharpenOperation(const GDALPansharpenOptions *)
Instantiate a pansharpening operation.
Definition: gdalpansharpen.cpp:1566
GDALRasterBandH hPanchroBand
Definition: gdalpansharpen.h:73
GDALRIOResampleAlg eResampleAlg
Definition: gdalpansharpen.h:61
int nOutPansharpenedBands
Definition: gdalpansharpen.h:87

Generated for GDAL by doxygen 1.8.6.