GDAL

nearblack_lib.h
1/******************************************************************************
2 *
3 * Project: GDAL Utilities
4 * Purpose: Convert nearly black or nearly white border to exact black/white.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 * ****************************************************************************
8 * Copyright (c) 2006, MapShots Inc (www.mapshots.com)
9 * Copyright (c) 2007-2013, Even Rouault <even dot 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 NEARBLACK_LIB_H
31#define NEARBLACK_LIB_H
32
33#ifndef DOXYGEN_SKIP
34
35#include "cpl_progress.h"
36#include "cpl_string.h"
37
38#include <string>
39#include <vector>
40
41typedef std::vector<int> Color;
42typedef std::vector<Color> Colors;
43
44struct GDALNearblackOptions
45{
47 std::string osFormat{};
48
50 GDALProgressFunc pfnProgress = GDALDummyProgress;
51
53 void *pProgressData = nullptr;
54
55 int nMaxNonBlack = 2;
56 int nNearDist = 15;
57 bool bNearWhite = false;
58 bool bSetAlpha = false;
59 bool bSetMask = false;
60
61 bool bFloodFill = false;
62
63 Colors oColors{};
64
65 CPLStringList aosCreationOptions{};
66};
67
68bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions,
69 GDALDatasetH hSrcDataset,
70 GDALDatasetH hDstDS,
71 GDALRasterBandH hMaskBand, int nBands,
72 int nDstBands, bool bSetMask,
73 const Colors &oColors);
74
75bool GDALNearblackFloodFill(const GDALNearblackOptions *psOptions,
76 GDALDatasetH hSrcDataset, GDALDatasetH hDstDS,
77 GDALRasterBandH hMaskBand, int nSrcBands,
78 int nDstBands, bool bSetMask,
79 const Colors &oColors);
80
81#endif // DOXYGEN_SKIP
82
83#endif // NEARBLACK_LIB_H
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:449
cpl_string.h
Various convenience functions for working with strings and string lists.
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:291
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:294
GDALNearblackOptions
struct GDALNearblackOptions GDALNearblackOptions
Definition: gdal_utils.h:153