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

C API

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

AUTHOR

92       Frank Warmerdam <warmerdam@pobox.com>
93
95       1998-2021
96
97
98
99
100                                 Jan 05, 2021                     NEARBLACK(1)
Impressum