Generate a "Thermal Cloud" Visualization (Phyllotaxis Layout)
Source:R/visualization.r
plot_thermal_cloud.RdArranges a collection of segmented thermal objects into an organic, spiral "cloud" formation. Unlike a rigid grid, this layout uses a golden-angle spiral (phyllotaxis) algorithm to cluster subjects efficiently. This is particularly effective for visualizing the diversity of thermal phenotypes in large datasets or creating artistic figures for presentations and covers.
Usage
plot_thermal_cloud(
img_list,
spread_factor = 1.1,
jitter_factor = 0.5,
palette = "inferno",
text_color = "black",
text_size = 3,
show_labels = TRUE
)Arguments
- img_list
A list of 'BioThermR' objects. For best results, these should be pre-processed (e.g., background removed via
roi_filter_threshold).- spread_factor
Numeric. Multiplier for the distance between objects. Values > 1.0 increase spacing (airier cloud), values < 1.0 pack objects tighter. Default is 1.1.
- jitter_factor
Numeric. Introduces random noise to the placement coordinates to break perfect symmetry and create a more natural look. Default is 0.5.
- palette
String. The color palette from the 'viridis' package. Default is "inferno".
- text_color
String. Color of the filename labels. Default is "black".
- text_size
Integer. Font size for the labels. Default is 3.
- show_labels
Logical. If
TRUE, displays the filename below each object. Default isTRUE.
Details
The function performs object-centric rendering:
Extraction: For each image, it extracts only the valid foreground pixels (non-NA), ignoring the original frame dimensions.
Re-centering: Each object is mathematically centered at (0,0) relative to its own coordinate system.
Placement: Objects are placed along a spiral path defined by the Golden Angle (~137.5 degrees).
The spacing and randomness of the spiral can be tuned using spread_factor and jitter_factor.
Examples
# \donttest{
# Load a batch of images
img_obj_list <- system.file("extdata",package = "BioThermR")
batch <- read_thermal_batch(img_obj_list)
#> Reading 30 files...
#> Batch read completed. Imported 30 files.
batch <- lapply(batch, roi_segment_ebimage)
#> Auto-Segmentation: Kept largest object ( 401 pixels )
#> Auto-Segmentation: Kept largest object ( 388 pixels )
#> Auto-Segmentation: Kept largest object ( 419 pixels )
#> Auto-Segmentation: Kept largest object ( 342 pixels )
#> Auto-Segmentation: Kept largest object ( 356 pixels )
#> Auto-Segmentation: Kept largest object ( 327 pixels )
#> Auto-Segmentation: Kept largest object ( 390 pixels )
#> Auto-Segmentation: Kept largest object ( 455 pixels )
#> Auto-Segmentation: Kept largest object ( 409 pixels )
#> Auto-Segmentation: Kept largest object ( 330 pixels )
#> Auto-Segmentation: Kept largest object ( 325 pixels )
#> Auto-Segmentation: Kept largest object ( 320 pixels )
#> Auto-Segmentation: Kept largest object ( 388 pixels )
#> Auto-Segmentation: Kept largest object ( 419 pixels )
#> Auto-Segmentation: Kept largest object ( 414 pixels )
#> Auto-Segmentation: Kept largest object ( 366 pixels )
#> Auto-Segmentation: Kept largest object ( 353 pixels )
#> Auto-Segmentation: Kept largest object ( 347 pixels )
#> Auto-Segmentation: Kept largest object ( 399 pixels )
#> Auto-Segmentation: Kept largest object ( 407 pixels )
#> Auto-Segmentation: Kept largest object ( 382 pixels )
#> Auto-Segmentation: Kept largest object ( 298 pixels )
#> Auto-Segmentation: Kept largest object ( 349 pixels )
#> Auto-Segmentation: Kept largest object ( 362 pixels )
#> Auto-Segmentation: Kept largest object ( 412 pixels )
#> Auto-Segmentation: Kept largest object ( 393 pixels )
#> Auto-Segmentation: Kept largest object ( 371 pixels )
#> Auto-Segmentation: Kept largest object ( 387 pixels )
#> Auto-Segmentation: Kept largest object ( 362 pixels )
#> Auto-Segmentation: Kept largest object ( 389 pixels )
# Create an artistic thermal cloud
p_cloud <- plot_thermal_cloud(batch, spread_factor = 1.5, jitter_factor = 2.0)
#> Processing objects...
#> Generating layout for 30 objects...
# }