2.3 Optical Images

In order to make the images usable for plotting alongside other data, they need to be cropped to the scanned area and referenced to the position or a depth variable. The initial crop can be supressed using trim = FALSE if the whole image is desired. Images in R are read in as a matrix with 3 dimensions (length, width, and the three colours). The data can be imported using itraxR::itrax_image(). This function can produce a basic diagram (shown in subsequent section), but here we focus on the structure of the imported object. $image is a three dimensional array, the first two dimensions are the length of the core and the width, respectively. Those two dimensions have "dimnames" (rownames() and colnames() respectively). For the rownames(), this is an interpolated position, in mm, and for the colnames() this is the width in mm, and always begins at 0. The last dimension always has a length of three, and comprises of the red, green and blue values for each of the pixels. $meta is a table containing selected data from the scan metadata relevant to the image.

itrax_image(file = "CD166_19_S1/CD166_19_S1/optical0.tif",
            meta = "CD166_19_S1/CD166_19_S1/document.txt",
              trim = FALSE) %>% 
  str()
## List of 2
##  $ image: num [1:7452, 1:524, 1:3] 0.0745 0.0745 0.0745 0.0824 0.0824 ...
##   ..- attr(*, "dimnames")=List of 3
##   .. ..$ : chr [1:7452] "0.5" "0.688001610522078" "0.876003221044155" "1.06400483156623" ...
##   .. ..$ : chr [1:524] "0" "0.187976382179281" "0.375952764358561" "0.563929146537842" ...
##   .. ..$ : NULL
##  $ meta :'data.frame':   6 obs. of  3 variables:
##   ..$ Parameter: chr [1:6] "Start coordinate" "Stop coordinate" "Step size" "Optical Start" ...
##   ..$ Value    : chr [1:6] "31.5" "1314.1" "1000" "0.5" ...
##   ..$ Unit     : chr [1:6] "mm" "mm" "microns" "mm" ...