Process root images by filling holes and optionally smoothing edges
Source:R/clean_binary_image.R
clean_root_image.Rd
Process root images by filling holes and optionally smoothing edges
Usage
clean_root_image(
img,
remove_small_particles = TRUE,
min_size = 100,
connectivity = 8,
fill_holes = TRUE,
min_hole_size = 1,
max_hole_size = Inf,
smooth_edges = FALSE,
kernel_shape = "disk",
kernel_size = 3,
iterations = 1
)
Arguments
- img
A binary image of root systems (imager cimg object)
- remove_small_particles
Boolean indicating whether only big objects are retained
- min_size
Minimum particle size (in pixel). Removing all patches below the minimal size
- connectivity
Determines which connection type is used to assess whether pixel belong to the same patch: 4 or 8
- fill_holes
Boolean indicating whether to fill holes
- min_hole_size
Minimum size of holes to fill (in pixels)
- max_hole_size
Maximum size of holes to fill (in pixels, Inf means no limit)
- smooth_edges
Boolean indicating whether to smooth edges
- kernel_shape
Shape of the kernel for edge smoothing: "square", "diamond", or "disk"
- kernel_size
Size of the kernel for edge smoothing (odd integer)
- iterations
Number of iterations for the smoothing process
Examples
data("seg_Oulanka2023_Session01_T067")
img <- seg_Oulanka2023_Session01_T067
# Fill holes only
result1 <- clean_root_image(img, fill_holes = TRUE, smooth_edges = FALSE)
#> Warning: Assuming third dimension corresponds to colour
#> Warning: Assuming third dimension corresponds to time/depth
#> Error in `[.pixset`(hole_mask, nrow(hole_mask), ): object 'hole_mask' not found
# Fill holes and smooth edges
result2 <- clean_root_image(img, fill_holes = TRUE, smooth_edges = TRUE)
#> Warning: Assuming third dimension corresponds to colour
#> Warning: Assuming third dimension corresponds to time/depth
#> Error in `[.pixset`(hole_mask, nrow(hole_mask), ): object 'hole_mask' not found
plot(result2)
#> Error: object 'result2' not found