# In this example there are 2 white root pixels in the skeleton image.
# The left one is completely surrounded by white pixels in the base image,
# it falls into Category 2 (3-7px). The bottom right one has a black
# neighboring pixel and thus falls in to Category 1 (<3px). Thus, the result
# is Categorie 1: 1 pixel, Cat. 2: 1 pixel, Cat. 3: 0 pixels.
skelPxWidth(base_img = matrix(c(1,1,1,0,
1,1,1,0,
1,1,1,1), ncol = 4, nrow = 3, byrow = TRUE),
skel_img = matrix(c(0,0,0,0,
0,1,0,0,
0,0,0,1), ncol = 4, nrow = 3, byrow = TRUE))
# Similar example with a mask which makes the function "ignore" the right
# side of the skeleton image.
# The function still identifies the left white pixel as of Category 2.
skelPxWidth(matrix(c(1,1,1,0,
1,1,1,0,
1,1,1,1), ncol = 4, nrow = 3, byrow = TRUE),
matrix(c(0,0,0,0,
0,1,0,0,
0,0,0,1), ncol = 4, nrow = 3, byrow = TRUE),
matrix(c(TRUE,TRUE,FALSE,FALSE,
TRUE,TRUE,FALSE,FALSE,
TRUE,TRUE,FALSE,FALSE), ncol = 4, nrow = 3,
byrow = TRUE))
Run the code above in your browser using DataLab