knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(hyperSpec) library(hyperSpec.utils)
spcmap_explorer()
can be used to interactively visualize spatially resolved spectral data, to show the spectral map at a certain band and to show a spectrum at a specific pixel location. This way the (hypothetical) spectral hypercube is "sliced" into two very familiar 2D representations.
Start the app as follows:
spcmap_explorer(chondro)
if you have high images it is probably convenient to flip x and y axis of the spectral map.
spcmap_explorer(chondro, flip = TRUE)
Use your mouse and select the area you want to zoom to by holding the left mouse button.
knitr::include_graphics("spcmap_explorer_zoom.gif")
Using the defaults for the argument fixed_y
, the y range is scaled to the the range of the complete dataset. Using FALSE
, the function is started in autoscale mode, by providing a numeric vector the start range can be set manually for the spectum plot.
spcmap_explorer(chondro, fixed_y = c(0, 1200))
If you want to compare intensities at multiple positions you likely want the y range to stay constant which is the case until you press the autoscale button. The y range is fixed again as soon as you select a new range interactively or pan the axis.
knitr::include_graphics("spcmap_explorer_y-scale.gif")
Sometimes you are not interested in the variation over the intensity range of the complete dataset, but want to map a specific intensity range to the dynamic range of the color ramp to point out certain spatial variation. You can do that interactively, using the sliders in the title bar.
knitr::include_graphics("spcmap_explorer_color-scale.gif")
The function cubeview()
can be used to interactively explore a spectral hypercube. {hyperSpec.utils} provides a wrapper for the function to use it on hyperspec objects.
Use the LEFT / RIGHT arrow keys and DOWN / UP arrow keys to set the slicing positions of the x-axis and y-axis, PAGE_DOWN / PAGE_UP keys for the z-axis. Press SPACE to show or hide guides. Use the left mouse-button to rotate, right mouse button to pan the hypercube. If you use the function inside RStudio, the Viewer pane may not display the cube. In that case, click on "Show in new window" to open it in a browser.
cubeview(chondro[ , , 700~800])
knitr::include_graphics("cubeview.gif")
In case you prefer the viridis color ramp you can specify it using the argument col.regions
.
cubeview(chondro[ , , 700~800], col.regions = viridis::viridis)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.