Abstract

I n this instalment we have special guest authors from Dr Carl Sullivan’s hyperspectral imaging group at the Dublin Institute of Technology. They will show us how to make some nifty videos from hyperspectral data using Rstudio and ImageJ. The dataset used in the analysis “Brd_HSI” will be available for download from http://dx.doi.org/10.1255/nirn.1483. This tutorial will cover the use of R (http:// www.r-project.org) in conjunction with ImageJ (Figure 2) to construct animations based on data obtained from a hypercube, which is a structure that naturally arises from the collection of hyperspectral data (Figure 3). In this article, we have used Rstudio (Figure 1) which is an integrated development environment (IDE) for R and thus allows the user to run R in a more user-friendly environment. The Rstudio (http://www.rstudio. com) interface consists of four windows namely: a) console, b) workspace and history, c) files, plots, packages and help and d) the R script(s) and data view. The example data presented in this article consists of a hyperspectral image of a slice of bread. This bread was manufactured by the authors to meet specific nutritional attributes. It will be assumed that the reader is aware of such libraries as caTools in R for importing hyperspectral data. The authors will also assume that the reader is familiar with image generation in R using such commands as image.plot in the fields library. First, we will use the command read. ENVI to import the hyperspectral data, Brd_HSI, into the R workspace. This data set will simply be referred to as Bread. It is good practice to check the dimensions of the data set; this can be achieved using the command dim. >Bread dim (Bread) [1] 256 246 103 Since the data is in our workspace, the image can be generated using the function image.plot. >image.plot(Bread[,,1],axes= FALSE, main=950nm) This should generate a nice image corresponding to the first wavelength of the bread data (Figure 4). Note axes=FALSE and main=950nm removes any labelling of the axes and gives a title to the image, respectively. Now we will write a function to generate an image at every wavelength so we should end up with a total of 103 images. We will want to store all these images. R can create, for example, a directory on your C drive with the dir.create command. >dir.create(c://im_seq) The folder im_seq should now appear on your C drive and this is where all the images generated will be placed. The function which will generate this sequence will be referred to as im_seq.func and it must be capable of generating an appropriate name for each image and placing an appropriate title above each image. im_seq.func<-function (x=Bread) { for(i in 1:103){ im_name<-paste (c://im_seq//,(943+7*i), nm.jpeg,sep=) jpeg(im_name) Figure 1. Rstudio interface.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call