Package 'agrifeature'

Title: Agriculture Image Feature
Description: Functions to calculate Gray Level Co-occurrence Matrix(GLCM), RGB-based Vegetative Index(RGB VI) and Normalized Difference Vegetation Index(NDVI) family image features. GLCM calculations are based on Haralick (1973) <doi:10.1109/TSMC.1973.4309314>.
Authors: Chun-Han Lee [aut] <[email protected]> Li-Yu Daisy Liu [aut] <[email protected]>
Maintainer: Chun-Han Lee <[email protected]>
License: GPL-3
Version: 1.0.3
Built: 2024-11-27 06:46:04 UTC
Source: CRAN

Help Index


Gray Level Co-occurrence Matrix(GLCM).

Description

This function calculate Gray Level Co-occurrence Matrix(GLCM), which can be used to describe texture of the image. The default parameters is distance = 1, angle = 0, gray level = 8

Usage

GLCM(x, d = 1, angle = 0, ngray = 8, grayscale = c(0,255), symmetric = TRUE, prob = FALSE)

Arguments

x

A numeric matrix.

d

an integer value, the distance between the current pixel, and the pixel to which it is compared.

angle

one of "0", "45", "90" or "135", the pixel to which the current pixel is compared.

ngray

an integer value, the number of gray levels to use in calculate GLCM.

grayscale

a vector which contain c(min,max) to set the range of value , if NULL grayscale will be set into the min and max value in x.

symmetric

Logical value, if TRUE (default) the matrix will be turn into a symmetric GLCM.

prob

Logical value, if TRUE (default) the matrix will be normalized such that the sum of it's components is 1.

Value

A GLCM with dimension ngray*ngray table. Each column and row represent a gray level in the image matrix.

References

Hall-Beyer, M. (2000). GLCM texture: a tutorial. National Council on Geographic Information and Analysis Remote Sensing Core Curriculum, 3, 75.

Examples

# generate an image data matrix with range 0~255
set.seed(100)
m <- matrix(sample(0:255,64), nrow=8, ncol=8)

# calculate GLCM with defalut parameters
GLCM.m <- GLCM(m)

# calculate probability GLCM
GLCM.m.p <- GLCM(m,prob = TRUE)

NDVI

Description

This function calculate NDVI value from input near-infrared (NIR) and red bands images. If change the input from red band into green or red-edge band values, it will return GNDVI or NDRE values.

Usage

NDVI(NIR, R)

Arguments

NIR

a dataframe or matrix contains NIR band values.

R

a dataframe or matrix contains red band values, NIR and R should have same class and dimension..

Value

A matrix or dataframe(depends on the class of NIR and R).

References

De Swaef, T., Maes, W. H., Aper, J., Baert, J., Cougnon, M., Reheul, D., ... & Lootens, P. (2021). Applying RGB-and thermal-based vegetation indices from UAVs for high-throughput field phenotyping of drought tolerance in forage grasses. Remote Sensing, 13(1), 147.


RGB based Vegetative Indexes (RGBVI)

Description

This function calculate some useful RGB based vegetative indexes.

Usage

RGBVI(R, G, B, vi = c('RCC','GCC','ExG2','ExR','ExGR'
,'GRVI','VDVI','VARI','MGRVI','CIVE','VEG'))

Arguments

R

a dataframe or matrix contains 'red' values, RGB should have same class and dimension..

G

a dataframe or matrix contains 'green' values, RGB should have same class and dimension.

B

a dataframe or matrix contains 'blue' values, RGB should have same class and dimension..

vi

vegetative indexes to be calculated(see Details).

Details

The vi parameter should be a characteristic vector and include at least one of the following VI: 'RCC','GCC','ExG2','ExR','ExGR','GRVI','VDVI','VARI','MGRVI','CIVE','VEG'. By default, all of the VIs will be calculated.

Value

A list with length(vi). Each elements represent a vegetative index matrix or data frame.

References

De Swaef, T., Maes, W. H., Aper, J., Baert, J., Cougnon, M., Reheul, D., ... & Lootens, P. (2021). Applying RGB-and thermal-based vegetation indices from UAVs for high-throughput field phenotyping of drought tolerance in forage grasses. Remote Sensing, 13(1), 147.

Examples

# generate R, G, B matrix with range 0~255
R <- matrix(sample(0:255,25), nrow=5, ncol=5)
G <- matrix(sample(0:255,25), nrow=5, ncol=5)
B <- matrix(sample(0:255,25), nrow=5, ncol=5)

# calculate all available rgb vi
vi.all <- RGBVI(R,G,B)

# calculate RCC,GCC,ExGR,MGRVI
vi.4 <- RGBVI(R,G,B,vi=c('RCC','GCC','ExGR','MGRVI'))