image_index {pliman} | R Documentation |
Image indexes
Description
image_index()
Builds image indexes using Red, Green, Blue, Red-Edge, and NIR bands.
Generates a raster or density plot of the index values computed with
image_index()
.
Usage
image_index(
img,
index = NULL,
r = 1,
g = 2,
b = 3,
re = 4,
nir = 5,
return_class = c("ebimage", "terra"),
resize = FALSE,
has_white_bg = FALSE,
plot = TRUE,
nrow = NULL,
ncol = NULL,
max_pixels = 1e+05,
parallel = FALSE,
workers = NULL,
verbose = TRUE,
...
)
## S3 method for class 'image_index'
plot(x, type = c("raster", "density"), nrow = NULL, ncol = NULL, ...)
Arguments
img |
An |
index |
A character value (or a vector of characters) specifying the
target mode for conversion to a binary image. Use |
r , g , b , re , nir |
The red, green, blue, red-edge, and near-infrared bands of the image, respectively. Defaults to 1, 2, 3, 4, and 5, respectively. If a multispectral image is provided (5 bands), check the order of bands, which are frequently presented in the 'BGR' format. |
return_class |
The class of object to be returned. If |
resize |
Resize the image before processing? Defaults to |
has_white_bg |
Logical indicating whether a white background is present. If TRUE, pixels that have R, G, and B values equals to 1 will be considered as NA. This may be useful to compute an image index for objects that have, for example, a white background. In such cases, the background will not be considered for the threshold computation. |
plot |
Show image after processing? |
nrow , ncol |
The number of rows or columns in the plot grid. Defaults to
|
max_pixels |
integer > 0. Maximum number of cells to plot the index. If
|
parallel |
Processes the images asynchronously (in parallel) in separate
R sessions running in the background on the same machine. It may speed up
the processing time when |
workers |
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time. |
verbose |
If |
... |
Additional arguments passed to |
x |
An object of class |
type |
The type of plot. Use |
Details
The following indexes are available in pliman.
RGB color space
-
R
red -
G
green -
B
blue -
NR
normalized redR/(R+G+B)
. -
NG
normalized greenG/(R+G+B)
-
NB
normalized blueB/(R+G+B)
-
GB
green blue ratioG/B
-
RB
red blue ratioR/B
-
GR
green red ratioG/R
-
BI
brightness Indexsqrt((R^2+G^2+B^2)/3)
-
BIM
brightness Index 2sqrt((R*2+G*2+B*2)/3)
-
SCI
Soil Colour Index(R-G)/(R+G)
-
GLI
Green leaf index Vis Louhaichi et al. (2001)(2*G-R-B)/(2*G+R+B)
-
HI
Primary colours Hue Index (2*R-G-B)/(G-B) -
NDGRI
Normalized green red difference index (Tucker, 1979)(G-R)/(G+R)
-
NDGBI
Normalized green blue difference index(G-B)/(G+B)
-
NDRBI
Normalized red blue difference index(R-B)/(R+B)
-
I
R+G+B -
S
((R+G+B)-3*B)/(R+G+B)
-
L
R+G+B/3 -
VARI
A Visible Atmospherically Resistant Index(G-R)/(G+R-B)
-
HUE
Overall Hue Indexatan(2*(B-G-R)/30.5*(G-R))
-
HUE2
atan(2*(R-G-R)/30.5*(G-B)) -
BGI
B/G -
GRAY
0.299*R + 0.587*G + 0.114*B
-
GRAY2
((R^2.2+(1.5*G)^2.2+(0.6*B)^2.2)/(1+1.5^2.2+0.6^2.2))^1/2.2
-
GLAI
(25*(G-R)/(G+R-B)+1.25)
-
CI
Coloration Index(R-B)/R
-
SAT
Overhall Saturation Index(max(R,G,B) - min(R,G,B)) / max(R,G,B)
-
SHP
Shape Index2*(R-G-B)/(G-B)
-
RI
Redness IndexR**2/(B*G**3)
HSB color space
-
DGCI
Dark Green Color Index, based on HSB color space60\*((G - B) / (max(R, G, B) - min(R, G, B)))
CIE-Lab color space
-
L*
: relative luminance(0.2126 * R + 0.7152 * G + 0.0722 * B)
-
a*
:0.55*( (R - (0.2126 * R + 0.7152 * G + 0.0722 * B)) / (1.0 - 0.2126))
When type = "raster"
(default), the function calls plot_index()
to create a raster plot for each index present in x
. If type = "density"
,
a for loop is used to create a density plot for each index. Both types of
plots can be arranged in a grid controlled by the ncol
and nrow
arguments.
Value
A list containing Grayscale images. The length will depend on the number of indexes used.
A NULL
object
Author(s)
Tiago Olivoto tiagoolivoto@gmail.com
References
Nobuyuki Otsu, "A threshold selection method from gray-level histograms". IEEE Trans. Sys., Man., Cyber. 9 (1): 62-66. 1979. doi:10.1109/TSMC.1979.4310076
Examples
library(pliman)
img <- image_pliman("soybean_touch.jpg")
image_index(img, index = c("R, NR"))
# Example for S3 method plot()
library(pliman)
img <- image_pliman("sev_leaf.jpg")
# compute the index
ind <- image_index(img, index = c("R, G, B, NGRDI"), plot = FALSE)
plot(ind)
# density plot
plot(ind, type = "density")