doOBIA: Do an Object-based image analysis to classify gaps.

Description Usage Arguments Details Value References See Also Examples

Description

Do an Object-based image analysis with the aim of classify gaps in full-color-upward-looking hemispherical photographs.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
doOBIA(
  x,
  bin,
  z,
  seg = doPolarQtree(x, z, scaleParameter = 0.2),
  g1 = makePolarGrid(z),
  sampleSize = 50,
  k = 1,
  zlim = asAngle(c(30, 60)),
  calibration = FALSE
)

## S4 method for signature 'CanopyPhoto'
doOBIA(
  x,
  bin,
  z,
  seg = doPolarQtree(x, z, scaleParameter = 0.2),
  g1 = makePolarGrid(z),
  sampleSize = 50,
  k = 1,
  zlim = asAngle(c(30, 60)),
  calibration = FALSE
)

Arguments

x

CanopyPhoto.

bin

BinImage. The standard is a call to enhanceHP followed by a call to autoThr

z

ZenithImage.

seg

PolarSegmentation.

g1

PolarSegmentation. The default option is a PolarSegmentation created by calling makePolarGrid(z). To save time in batch processing of photos token with the same camera, you can compute makePolarGrid(z) only once and provide the result through this argument.

sampleSize

integer. Default is 50, see Details.

k

integer. Default is 1 nearest neighbor, see Details.

zlim

Angle. Defaults are 30 to 60 degrees of zenith angle, see Details.

calibration

logical. Default is FALSE, see Details.

Details

This algorithm uses object-based image analysis (OBIA). The class Gap-candidate is assigned to pixels that are white in bin and the class Plant to the rest of the pixels. Next, the algorithm uses this result and g1 to isolate hemisphere segments with 1 degree of resolution that are not fully cover by Plant (i.e., Gap Fraction > 0), which are classified as Mix-OR-Gap. Next, the algorithm get a binary mask from this result and intersect it with the argument seg. At this point, the algorithms achieve the identification of all segments of seg that could have some gaps at pixel level (i.e., Mix-OR-Gap). Next, the algorithm classified all this segments in Gap or Mix in a two stage process: (1) automatic selection of samples and (2) sample-based classification. The argument sampleSize controls the sample size for both targeted classes. The algorithm uses the brightness of the blue channel to select the samples. It assumes that brighter objects belong to Gap and objects with middle brightness belong to Mix. The argument k is for the knn used in the second stage of the sample-based classification. Processing continues on Mix-segments in order to unmix them at pixel level (see references for more details). The arguments mnZ and mxZ can be used to delimitate the range of zenith angle in which the aforementioned process is computed. In the rest of the image the result will be the same as bin.

If calibrate is set as TRUE, the process stops just after the sample-based classification described in the previous paragraph and returns a classification at object level of Plan, Mix and Gap. This kind of output can be used to calibrate sampleSize and k.

Value

A BinImage by default. If calibrate is set to TRUE, a RasterLayer.

References

Diaz, G.M., Lencinas, J.D., 2015. Enhanced Gap Fraction Extraction From Hemispherical Photography. IEEE Geosci. Remote Sens. Lett. 12, 1784-1789.

See Also

loadPhoto, doPolarQtree, makeZimage.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
x <- loadPhoto()
x <- normalize(x, 0, 255)
z <- makeZimage(ncol(x), lensPolyCoef(c(0.6427, 0.0346, -0.024491)))
m <- doMask(z)
bin <- autoThr(enhanceHP(x, m, sharpen = FALSE))


# Because next line takes too long for an example...
## Not run: 
  seg <- doPolarQtree(x, z, scaleParameter = 0.1)

## End(Not run)
# ... you can open the result with the following lines.
seg <- raster(system.file("external/seg.tif", package="caiman"))
seg <- as(seg, "PolarSegmentation")

g1 <- makePolarGrid(z)
zlim <- asAngle(c(20, 80))

out <- doOBIA(x, bin, z, seg, g1, zlim = zlim, sampleSize = 20, calibration = FALSE)
plot(out)
out <- doOBIA(x, bin, z, seg, g1, zlim = zlim, sampleSize = 20, calibration = TRUE)
plot(out)

zlim <- asAngle(c(30, 60))

out <- doOBIA(x, bin, z, seg, g1, zlim = zlim, sampleSize = 20, calibration = TRUE)
plot(out)



# Fullframe

path <- system.file("external/DSC_2881.jpg", package="caiman")
x <- loadPhoto(path)
### declaring it as a fullframe
fisheye(x) <- newFishEye(TRUE, TRUE, TRUE)

x <- normalize(x, 0, 255)

lens <- lensPolyCoef(c(0.71553, 0.01146, -0.03928))
angle <- asAngle(c(53))
pix <- c(224)
diameter <- calcDiameter(lens, pix, angle)
z <- makeZimage(diameter, lens)

m <- doMask(x, z)
x <- expandFullframe(x, z)

bin <- autoThr(enhanceHP(x, m, sharpen = FALSE))


seg <- doPolarQtree(x, z, scaleParameter = 0.2, mnSize = 1000)
out <- doOBIA(x, bin, z, seg, sampleSize = 20, calibration = TRUE)
plot(out)
out <- doOBIA(x, z, seg, sampleSize = 20, calibration = FALSE)
plot(out)

GastonMauroDiaz/caiman documentation built on Jan. 22, 2022, 4:43 a.m.