1NEARBLACK(1)                         GDAL                         NEARBLACK(1)
2
3
4

NAME

6       nearblack - Convert nearly black/white borders to black.
7

SYNOPSIS

9          nearblack [-of format] [-white | [-color c1,c2,c3...cn]*] [-near dist] [-nb non_black_pixels]
10                    [-setalpha] [-setmask] [-o outfile] [-q]  [-co "NAME=VALUE"]* infile
11

DESCRIPTION

13       This  utility  will  scan  an  image and try to set all pixels that are
14       nearly or exactly black, white or one or more custom colors around  the
15       collar  to  black  or  white. This is often used to "fix up" lossy com‐
16       pressed air photos so that color pixels can be treated  as  transparent
17       when  mosaicing. The output format must use lossless compression if ei‐
18       ther alpha band or mask band is not set.
19
20       -o <outfile>
21              The name of the output file to be created.
22
23       -of <format>
24              Select the output format.  Starting with GDAL 2.3, if not speci‐
25              fied,  the  format is guessed from the extension (previously was
26              ERDAS Imagine .img).  Use the short format name (GTiff for  Geo‐
27              TIFF for example).
28
29       -co `"NAME=VALUE"`
30              Passes  a creation option to the output format driver.  Multiple
31              -co options may be listed. See  raster_drivers  format  specific
32              documentation for legal creation options for each format.
33
34              Only valid when creating a new file
35
36       -white Search  for  nearly  white  (255) pixels instead of nearly black
37              pixels.
38
39       -color <c1,c2,c3...cn>
40              Search for pixels near the specified  color.  May  be  specified
41              multiple  times.   When -color is specified, the pixels that are
42              considered as the collar are set to 0.
43
44       -near <dist>
45              Select how far from black, white or custom colors the pixel val‐
46              ues  can  be  and  still  considered near black, white or custom
47              color.  Defaults to 15.
48
49       -nb <non_black_pixels>
50              number of non-black pixels that can be  encountered  before  the
51              giving up search inwards. Defaults to 2.
52
53       -setalpha
54              Adds an alpha band if the output file is specified and the input
55              file has 3 bands, or sets the alpha band of the output  file  if
56              it  is specified and the input file has 4 bands, or sets the al‐
57              pha band of the input file if it has 4 bands and no output  file
58              is  specified.   The  alpha band is set to 0 in the image collar
59              and to 255 elsewhere.
60
61       -setmask
62              Adds a mask band to the output file, or adds a mask band to  the
63              input file if it does not already have one and no output file is
64              specified.  The mask band is set to 0 in the image collar and to
65              255 elsewhere.
66
67       -q     Suppress progress monitor and other non-error output.
68
69       <infile>
70              The input file.  Any GDAL supported format, any number of bands,
71              normally 8bit Byte bands.
72
73       The algorithm processes the image one scanline at a time.  A scan  "in"
74       is done from either end setting pixels to black or white until at least
75       "non_black_pixels" pixels that are more than "dist"  gray  levels  away
76       from black, white or custom colors have been encountered at which point
77       the scan stops.  The nearly black, white or custom color pixels are set
78       to black or white. The algorithm also scans from top to bottom and from
79       bottom to top to identify indentations in the top or bottom.
80
81       The processing is all done in 8bit (Bytes).
82
83       If the output file is omitted, the processed results  will  be  written
84       back to the input file - which must support update.
85

C API

87       This utility is also callable from C with GDALNearblack().
88
89       New in version 2.1.
90
91

AUTHOR

93       Frank Warmerdam <warmerdam@pobox.com>
94
96       1998-2021
97
98
99
100
101                                 Sep 07, 2021                     NEARBLACK(1)
Impressum