development of software for spectral imaging data acquisition using labview

8

Click here to load reader

Upload: weilin-wang

Post on 05-Sep-2016

240 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Development of software for spectral imaging data acquisition using LabVIEW

Computers and Electronics in Agriculture 84 (2012) 68–75

Contents lists available at SciVerse ScienceDirect

Computers and Electronics in Agriculture

journal homepage: www.elsevier .com/locate /compag

Development of software for spectral imaging data acquisition using LabVIEW

Weilin Wang a, Changying Li a,⇑, Ernest W. Tollner b, Glen C. Rains a

a Biological and Agricultural Engineering, University of Georgia, Tifton, GA 31793, USAb Biological and Agricultural Engineering, University of Georgia, Athens, GA 30602, USA

a r t i c l e i n f o

Article history:Received 2 June 2011Received in revised form 31 January 2012Accepted 20 February 2012

Keywords:Hyperspectral imagingSoftwareData acquisitionLabVIEWLCTFFinite state machine

0168-1699/$ - see front matter Published by Elsevierhttp://dx.doi.org/10.1016/j.compag.2012.02.010

⇑ Corresponding author. Tel.: +1 229 386 3915; faxE-mail addresses: [email protected] (W. Wang), cy

engr.uga.edu (E.W. Tollner), [email protected] (G.C. Rai

a b s t r a c t

Developing data acquisition software is a major challenge in integrating a spectral imaging system. Thispaper presents the design and implementation of a data acquisition program using LabVIEW for a liquidcrystal tunable filter based spectral imaging system (900–1700 nm). The module-based program wasdesigned in a three-tier structure. The image acquisition process, modelled by a finite state machine,was implemented in LabVIEW to control the spectral imaging system to collect hyperspectral or multi-spectral images. The collected spectral images were encoded in general format and could be further pro-cessed by other common spectral image analysis tools. In addition, the program could be used to observeband ratio images of the test object in real-time, collect spectral images after ensemble averaging, andselect region of interest for spectral image acquisitions. This program is a useful data acquisition toolfor the filter-based spectral imaging system. The design and implementation techniques described in thisarticle could also be used to develop similar spectral image acquisition programs.

Published by Elsevier B.V.

1. Introduction

In the past decade, spectral imaging, including hyperspectralimaging (HSI) and multispectral imaging (MSI), has been widelyused for non-destructive inspections in various areas such as re-mote sensing (Chang, 2007), biomedical imaging (Schwartz,2005), food safety and quality (Sun, 2010), surveillance (Denmanet al., 2010), and conservation (Fischer and Kakoulli, 2006). A spec-tral imaging system acquires the spectral and spatial informationof the test object simultaneously and stores the collected informa-tion into a three dimensional data matrix (a spectral image). Thelarge amount of information contained in spectral images enablesresearchers to investigate both the spectral and spatial characteris-tics of the test object more efficiently (Lu and Chen, 1998).

Liquid crystal tunable filter (LCTF) is an electronically tuned fil-ter which selects a narrow band of light at a specific wavelength fortransmission and blocks all others (Gat, 2000). The LCTF-basedspectral imaging is an important branch in spectral imaging andhas been widely employed for non-destructive sensing (Singhet al., 2010; Williams et al., 2009; Gebhart et al., 2007). It has sev-eral advantages in instantaneous imaging, such as wide field ofview and adjustable camera exposure time in scanning (Wanget al., 2011).

An LCTF-based spectral imaging system is a complex integrationof optical and electronic hardware components requiring sophisti-

B.V.

: +1 229 386 [email protected] (C. Li), btollner@

ns).

cated software (Gat, 2000). Currently, some commercial and opensource software tools, such as ENVI (ITT Visual Information Solu-tions, Boulder, CO, USA) and MATLAB-based hyperspectral imageanalysis toolbox (HIAT) (Jimnez et al., 2011), are available for visu-alizing and analyzing spectral images. However, a general spectralimage acquisition software package for the LCTF-based system isstill not readily available. Some manufacturers of LCTF-based spec-tral imaging systems provide commercial data acquisition softwarepackages. This kind of commercial software, however, is often lim-ited by its lack of flexibility and extensibility, which are highlydesirable features for research oriented applications. For instance,a small change of the illumination in a spectral imaging systemwould require a re-calibration of the system, which is often han-dled by software. As a result, many researchers and engineers haveto rely on customized software to meet their specific requirements.

A well-designed architecture is a critical factor for the success ofany data acquisition software (Bass et al., 2003). In modern soft-ware engineering, the architecture of a software program usuallyfollows one or several design patterns. The finite state machine(FSM), which is often described as a ‘‘Moore machine’’, is a designpattern for implementing complex decision-making algorithms(Wagner et al., 2006). The FSM pattern provides good support forboth design and implementation phases in software development.It allows dynamic control of the system by defining the operationof the system to a number of states and providing flexible transi-tions between states. Due to its effectiveness and high flexibility,FSM is one of the most common software structures used for con-trolling systems (Wagner et al., 2006) and real-time applications(Williams, 2006).

Page 2: Development of software for spectral imaging data acquisition using LabVIEW

W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75 69

Although most publications of the spectral imaging applicationsdescribed their software programs, only a few of them presentedthe design and the architecture of their data acquisition software.Lerner and Drake (1999) demonstrated the design of a LabVIEWprogram for a push-broom microscopy hyperspectral imaging sys-tem (385–750 nm), which can collect 242 spectra at each scannedline. However, the paper mainly presented the functions of thesoftware rather than discussing the methodologies for designingthe program. Yoon et al. (2011) briefly presented their softwaresolution for real-time inspection of fecal and ingesta on poultrycarcasses using line-scan hyperspectral imaging system. In theirapplication, multi-thread programming and double bufferingmemory management were applied to increase the processingspeed of their online inspection program. Overall, to our knowl-edge, there are few publications that discussed the general designand implementation methods of data acquisition software for thespectral imaging system, particularly for an LCTF-based spectralimaging system.

This article aimed to demonstrate the whole process of the de-sign and implementation of a LabVIEW program, which integratedan LCTF-based spectral imaging system for data acquisition. Spe-cific objectives of this work were to: (1) design a reliable and flex-ible architecture for the spectral image acquisition program, (2)implement an easy-to-use program to integrate the hardware de-vices of the system to acquire hyperspectral/multispectral imagesin the spectral region of 900–1700 nm, and (3) develop several use-ful functions, such as collecting ensemble averaging images andpreviewing band ratio images, to enhance the usability of thesoftware.

2. Overview of the hardware

The system hardware mainly consisted of a spectral imager,illumination system, frame grabber, and computer. The key hard-ware component, the spectral imager, included a liquid crystal tun-able filter (Model Varispec LNIR 20-HC-20, Cambridge Research &Instrumentation, MA, USA), an InGaAs camera (Model SU320KTS-1.7RT, Goodrich, Sensors Unlimited, Inc., USA), and a lens (ModelSOLO 50, Goodrich, Sensors Unlimited, Inc., NJ, USA). The LCTFcan be tuned over the spectral region from 850 to 1800 nm with20 nm full-width at half-maximum (FWHM). The LCTF has a work-ing aperture of 20 mm and takes 50–150 ms to tune its bandpass toa specific wavelength. The InGaAs camera can capture 12-bit gray-scale images (320 � 256 pixel) with a maximum speed of 60frames per second (fps). A frame grabber (NI PCI-1426, NationalInstruments, Austin, TX, USA) was used to control the cameraand acquire image data. The lighting source was provided by four35 watts quartz halogen lamps (Model S4121, Superior Lighting,Fort Lauderdale, FL, USA). A digital color CCD camera (LifeCam Cin-ema, Microsoft, Redmond, WA, USA) was applied to collect thecomplementary color information of the test object since the InG-aAs camera collected images in the near-infrared range.

3. Software design

3.1. Design criteria

The software was designed to provide a user-friendly dataacquisition program for researchers using the LCTF-based spectralimaging system. The major criterion was to ensure that the pro-gram can reliably acquire hyperspectral or multispectral images.Given the spectral imaging system would be used in different re-search applications, several other aspects were also considered inthe design of this program:

Usability all required functions of the program can be per-formed under the stated conditions and the interface of the pro-gram is friendly to its targeted users.Flexibility the program can be operated in flexible proceduresfor acquiring different types of spectral images.Reusability modules can be further used by future programswith slight modification or no modification.Extensibility new features can be added without significantchanges to the architecture of the program.Cost-efficiency the design of the software is easy to be imple-mented and the cost for developing, operating, and maintainingthe program is minimized.

3.2. Programming language selection

Many programming languages have been used to develop HSI/MSI software, such as C++ (Evans et al., 1998; Yoon et al., 2011),Microsoft Visual Basic (Kim et al., 2001), and LabVIEW (Lernerand Drake, 1999; Martin et al., 2006). Selection of a programmingplatform depends upon many factors, such as the skill of the devel-oper and available drivers of the hardware, etc. Among these pro-gramming languages, Laboratory Virtual Instrument EngineeringWorkbench (LabVIEW) has several advantages over other pro-gramming languages in terms of research use. A major advantageof LabVIEW is its rich graphic user interface (GUI) widgets andhardware drivers. For instance, for this spectral imaging system,the LabVIEW NI-IMAQdx toolset provides strong support for theserial communication between the computer and the InGaAs cam-era via the Camera Link interface. Moreover, LabVIEW is a graphicdataflow programming language based on virtual instruments(VIs), which are virtual representations of hardware equipment.Graphic programming allows programmers to implement pro-grams by quickly dragging and dropping icons. This unique charac-teristic shortens the time required for software development,which met our criterion of cost-efficiency. Thus, the LabVIEW(v8.2, National Instruments, Austin, TX, USA) was chosen to devel-op the software in this study.

3.3. Software architecture

Overall, this module-based program was designed in a three-tier structure (Fig. 1). The top tier is the graphic user interface(GUI) using a set of LabVIEW user interface controls. The low levelcommunication tier consists of a set of LabVIEW I/O functions (Na-tional Instruments, Austin, TX, USA) which send commands and re-ceive data to/from the hardware devices. The middle tier (datacollecting and processing) manipulates hardware and builds spec-tral images. The tier includes five modules: the InGaAs camera con-trol, LCTF control, USB color camera control, spectral imagereconstruction, and system configuration module. The core func-tions of each module are organized as independent virtual instru-ments (sub-VIs) to improve the reusability of the program. Detailsof these modules are introduced in the following sections.

3.4. Model for data acquisition

The data acquisition process was modeled by using an FSM toachieve high flexibility and extensibility. The FSM follows the de-sign pattern recommended by National Instruments, which con-sists of while loops, case structures, shift registers, andtransition codes. The overall data acquisition process has eightsegments and each segment executes a set of processes as a batchto complete a relatively independent task. These segments andrelated program status are modeled as states (Fig. 2). A statecan either be followed by another state, or wait for anotheruser/system event, depending on history activities and current

Page 3: Development of software for spectral imaging data acquisition using LabVIEW

Fig. 1. The three-tier structure of the data acquisition program.

Fig. 2. The state diagram of the finite state machine model used by the program.

70 W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75

user inputs. The overall process flow and transitions of states aremanaged by the FSM. The application starts a scan from an ‘‘ini-tialization’’ state, in which the program is loaded into the com-puter memory and starts to accept user’s input. In the ‘‘stop’’state, the program is closed by a sequence of clean up actions.States 2-7 model the main operations of the program for control-ling hardware devices and collecting images. Using the FSM, theprocess flow of spectral image acquisition can be altered flexiblyby adjusting the transition between states. In addition, adding orremoving process states can be implemented with small impactto other existing states, since the states are relatively indepen-dent from each other. For instance, to skip the color image acqui-sition (state 5), the program uses the transition link betweenstate 4 and state 6 in Fig. 2.

A typical spectral image acquisition process is illustrated inFig. 3. The system is first initialized to establish connections be-tween the computer and the LCTF, and between the computer

and the InGaAs camera. In the second step, the program acceptsa user’s input from the GUI. At this stage, the user could set param-eters, preview the color image, specify the directory for savingimages, preview spectral images at specific wavelengths, and thenstart an image acquisition process. The image acquisition process isstarted from capturing a color image, which is automatically savedto the predefined directory. Next, based on the parameters set bythe user, the head file for the spectral image is created and savedto the predefined directory. During the scanning of the object,the program iteratively tunes the LCTF to a specific wavelengthand synchronizes the InGaAs camera to take a snapshot of theview. The collected image data are sent to the image reconstruc-tion module in which they are appended to the spectral image file.After all wavelengths are scanned, the spectral image is automati-cally named and saved to the predefined directory. Then, the pro-gram completes the acquisition operation and returns to the imagepreview state.

Page 4: Development of software for spectral imaging data acquisition using LabVIEW

Fig. 3. The flow chart for the process of a typical spectral image acquisition.

Fig. 4. The flow chart for acquiring a snap-shot image using the NI-IMAQdx toolkit.

W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75 71

3.5. Implementation of key modules

3.5.1. The InGaAs camera moduleThe camera module controls the InGaAs camera to acquire

monochrome images through the frame grabber and displaysimages on the screen. The NI-IMAQdx toolset provides both low-level and high-level functions to control the camera. Low-levelfunctions can be used to directly control the hardware for imageacquisition, such as setting the camera attributes and accessingregisters. High-level functions encapsulate low level functions forcommon image acquisition operations. The camera module of thisprogram was mainly implemented based on high-level functions.

The NI-IMAQdx toolkit provides three methods to use high-le-vel image acquisition functions: snap, grab, and sequence. Thesnap method captures a single image to computer memory at eachacquisition. The grab method grabs a number of images continuallybut only the last image can be used for processing and analysis. Thesequence method acquires a specific number of images in a se-quence and all these images are saved into the internal buffersfor further processing. Since the spectral image acquisition needsto continuously take images at specified wavelength bands, the se-quence method was first considered due to its advantage of acquir-ing consecutive images at a high speed. However, a spectral imageoften contains large amount of data. If the sequence method isused, these data have to be cached in the limited internal and userbuffers, which would increase the complexity of programming andlead to the instability of the program. On the other hand, the spec-tral imaging system has to wait for 50–150 ms to tune the filter tothe next wavelength. This time period allows the InGaAs camera totake 3–9 pictures no matter which acquisition method is used,which was sufficient to most of our applications. Thus, the advan-tage for both the grab and sequence acquisition methods, in termsof speed, was less appealing to this system. Compared to grab/se-quence functions, the snap method is a more reliable and easy-to-use approach. Therefore, the snap function was used in thisprogram to meet the criterion of reliability.

The image acquisition using the snap method follows a stan-dard process (Fig. 4). During the initialization stage, a camera isidentified and a camera session is established. To start the camera

session, the camera name and camera control mode have to bespecified. The NI-IMAQdx toolset provides two camera controlmodes: controller or listener. The default controller mode can beused to control the camera and to receive data, while the listenermode can only be used to receive the data. Since the spectral imag-ing system needs to set camera parameters such as the exposuretime dynamically, the controller mode was used. In the program,the camera attributes are mainly configured by the InGaAs cameraconfiguration file using the National Instruments Measurement &Automation Explorer software (National Instruments, Austin, TX,USA). The camera attributes can also be changed in run-time byusing the low-level functions in NI-IMAQdx toolset. After configur-ing parameters, an image is acquired by applying the snap functionin which image data are captured and copied to the computermemory. Then, the 12-bit monochrome image data are encodedto the image type ‘‘Image_I16’’ (2 bytes per pixel) for processingand display. When the image acquisition is completed, the camerasession is closed and the camera is disconnected from thecomputer.

3.5.2. The LCTF moduleThe LCTF module tunes the LCTF to select wavelengths in the

spectral region of 900–1700 nm. Although the LCTF is connectedwith the computer via a USB interface, it is recognized as a virtualCOM device at 9600 baud rate in the LabVIEW. The manufacturerof the LCTF (Cambridge Research & Instrumentation, Inc., MA,USA) provides a software developer’s kit (SDK) to control the LCTF.The SDK includes a set of LabVIEW sub-VIs, which are fundamentalfunctions for operating the LCTF, such as tuning the wavelengthand checking the status of the LCTF.

To guarantee the performance and safety of the system, thetemperature of the LCTF should be monitored. The LCTF only al-lows a narrow band of light to pass through it and blocks light inall other spectral regions. Thus, the energy received by the LCTFis several hundred to several thousand times greater than the en-ergy received by the camera (CRI, 2007). The lighting source of thissystem (halogen lamps) emits immense heat carried by the light inthe infrared region. Since this system was designed in the nearinfrared region, it doesn’t block or reflect the infrared energy awayby using a filter or a dielectric hot-mirror. As a result, largeamounts of thermal energy are absorbed by the LCTF. Under cer-tain situations such as improper lighting, the accumulated energy

Page 5: Development of software for spectral imaging data acquisition using LabVIEW

72 W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75

could damage the LCTF. In addition, the performance of the LCTFvaries with the temperature of the optics module. When the LCTFencounters an excessive temperature change (�3 �C), it must be re-initialized to reduce the wavelength error (CRI, 2007). Thus, it isimportant to monitor the temperature of the LCTF during the sys-tem operation. This program queries the temperature of the LCTFevery 30 s when there is no image acquisition task. It also queriesthe temperature of the LCTF before each spectral image acquisitionoperation. The temperature (in centigrade) of the LCTF is displayedin the status window on the main GUI. When the temperature ofthe LCTF exceeds the threshold value (40 �C at default) pre-definedin the system configuration file, the program will pop up an alertwindow and put the LCTF in sleep mode.

3.5.3. The spectral image reconstructionThe spectral image reconstruction module constructs spectral

images in ENVI format which is a general encoding format for spec-tral images accepted by common spectral image analysis software(Fig. 5). In ENVI format, a spectral image consists of an ASCII headerfile and a binary image data file. The header file and the image datafile of a spectral image should have the same file name but with adifferent suffix. The header file of the spectral image stores the de-tailed format information of the image in keyword–value pairs.Critical keywords for a spectral image include: samples, lines,bands, file type, data type, header offset, interleave, band names,and byte order. When an image data file is loaded, the ENVI soft-ware will automatically search and read the header file for the for-mat information of the image. In this program, a LabVIEW sub-VIwas developed to automatically create, read, and write imageheader files.

There are three common methods to encode a spectral imagedata file: band sequential format (BSQ), band interleaved by pixelformat (BIP), and band interleaved by line format (BIL). The BSQ for-mat stores 2-D spatial images in a sequential order (band by band).The BIP format saves the spectra of pixels in succession, which firststores the spectrum of the first pixel across all bands, and thensaves the spectrum of the next pixel. The BIL format saves the firstline of the image at the first band, and then iteratively saves thesame line of the image at the following bands. Then, it saves theremaining lines for all bands successively. In this program, sincethe LCTF-based spectral imaging system collects 2-D images bandby band, the spectral images were encoded in BSQ format.

3.5.4. USB color camera controlThe digital color camera module was designed to control the

compact digital color camera. Using the LabVIEW USB camera

Fig. 5. LabVIEW diagram for co

universal toolset (NI-IMAQ for USB Cameras 1.0, National Instru-ments Corporation, TX, USA), the color camera control module iscompletely independent from the camera hardware. Thus, theUSB color camera can be easily replaced by any other camerasusing the USB interface without changing the software. The NI-IMAQ for USB camera provides two types of image acquisition ap-proaches: snap and grab, whose principles are similar with thesnap and grab image acquisition methods discussed in section3.5.1. In this module, the grab method was used to preview and ac-quire 32-bit RGB color images.

3.5.5. System configuration and log filesThe system has two configuration files. Each of them includes a

number of keyword–value pairs written in ASCII. One configura-tion file stores the default values for the global parameters of thesystem, such as the interface IDs of the camera and the LCTF, thedefault wavelength settings for image acquisition. The other con-figuration file contains the camera exposure time and gain valuesfor each wavelength in the spectral region of 900–1700 nm. Theconfiguration files were created outside the program using regulartext editors such as Microsoft Notepad (v5.1, Microsoft, Redmond,WA, USA) and managed by using LabVIEW configuration file VIs inthe program. Another text log file, in addition, is used to recordimportant user activities and system error/warning messagesoccurring during system operation. The log file is created and man-aged using LabVIEW file I/O functions.

3.5.6. Error handlingBefore each image acquisition operation, the program checks

the dependency and effectiveness of the critical parameters (thestate 4 in Fig. 2). The default parameters stored in the global con-figuration file will be applied if the user does not set parameter val-ues. The warning/error messages are displayed on the systemoutput panel or by a pop-up dialog box. Errors in other modulesare handled using the LabVIEW exception handling infrastructureand corresponding VIs.

4. Software demonstration

4.1. Graphic user interface (GUI)

The main user interface of the program (Fig. 6) includes five sec-tions: the image setting panel, LCTF setting panel, image previewwindow, system operation panel, and system status panel. In theimage setting panel, users set camera parameters, preview the im-age, and specify pre-processing methods for the image. In the LCTF

nstructing spectral images.

Page 6: Development of software for spectral imaging data acquisition using LabVIEW

W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75 73

setting panel, users select the image acquisition mode of the sys-tem between HSI and MSI using a two-item radio control on thetop of the panel. When image acquisition mode (HSI or MSI) is se-lected, the corresponding inputs are enabled to specify spectralbands that need to be scanned. The image preview panel is usedto show images before or during image scanning. The status panelconsists of a read-only text box for displaying result/help/warning/error messages. In addition to the main window, the programuses pop-up windows to select region of interest (ROI) in imageacquisition and to specify wavelengths in multispectral imageacquisition.

4.2. Hyperspectral image acquisition

Before image acquisition, system parameters should be set up inthe system configuration file. The user specifies the default valuesfor the essential parameters of the system, such as the interface IDof the InGaAs camera, the running mode of the InGaAs camera, theVISA name of the LCTF in LabVIEW, the shortest and longest wave-lengths of the system, and the maximum operating temperature ofthe LCTF. Once the default values of these parameters are set upand saved, they can be used in later scans unless these defaultvalues need to be changed. The user can also back up the systemconfiguration to a separate text file by clicking the ‘‘save configura-tion’’ button in the LCTF setting panel.

To acquire a hyperspectral image, the user must set up a start-ing wavelength, an ending wavelength, and the wavelength inter-val. All these values are integers using nanometers as units. Basedon these parameters, the LCTF module automatically calculates allwavelength numbers that need to be scanned. When the ‘‘sensitiv-ity correction’’ button is checked by the user, the program scansimages using the wavelength-dependent camera exposure timeand gain, which are pre-defined in the calibration configurationfile. This function can be used to correct the sensitivity of the spec-tral imaging system.

When all parameters are set up, users can tune the LCTF to aspecific wavelength and then preview the image by turning onthe ‘‘preview’’ function. After that, the user can start an image

Fig. 6. The main graphic user

acquisition process. During image acquisition, the collected imageswill be displayed on the preview window. After the spectral imageis saved to the defined path, the program shows a message on thesystem status panel and gives a sound notification. Then, the pro-gram returns to the image preview state to wait for the next acqui-sition operation.

To demonstrate the hyperspectral image acquisition, a disease-free sweet onion (cv. Century) was scanned from 950 to 1650 nmwith 2 nm increments using this program. The program used2 min and 35 s to complete the whole scan. The size of the cap-tured hyperspectral image was 54.8 megabytes. The hyperspectralimage of the onion contained 351 images (320 � 256 pixel) of theonion, or equivalently 320 � 256 spectra in the spectral region of950–1650 nm with 2 nm interval. Since it is difficult to presentall spectra and images from the hyperspectral image of the onion,nine images from nine wavelengths and the mean spectra from thebody and neck scales of the onion were extracted and displayed asa demonstration (Fig. 7). The images and spectra of the onion wereextracted using ENVI (v4.7, ITT Visual Information Solutions, Boul-der, CO, USA) software. As shown in Fig. 7(A), the onion body fleshyscales became increasingly dark in images taken at wavelengthslonger than 1400 nm, while the intensity values of onion neckscales didn’t change substantially. The reason is that the onionbody scales contained a high percentage of water, which had muchhigher absorbance at the spectral region of 1400–1650 nm. On theother hand, the dry neck scales of the onion contained less waterand thus their intensity values in images were not affected bythe water absorptions in the spectral region of 1400–1650 nm. Thischaracteristic was also confirmed by the mean spectra of the onionneck scale and body scale (Fig. 7(B)).

4.3. Multispectral image acquisition

Acquiring multispectral images is another major function of theprogram. The program provides a wizard (Fig. 8) to guide users toset up parameters. At the first step, the user should specify thenumber of bands and then click the ‘‘apply’’ button. Based on thenumber that the user sets, the wizard enables a number of inputs

interface of the program.

Page 7: Development of software for spectral imaging data acquisition using LabVIEW

74 W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75

for setting wavelengths. At step 2, the user inputs the wavelengthfor each band and the program checks the validity of the specifiedwavelength. Then, the user can review and confirm the specifiedwavelengths in step 3. When the user clicks the ‘‘OK’’ button, thespecified wavelengths are passed on to the main program andthe user can collect multispectral images of the test samples withan approach similar to acquiring hyperspectral images.

4.4. Band ratio image

The ratio image of two bands (band 1/band 2) is a widely usedtechnique in spectral imaging applications (Chen, 2008). The pro-gram has the function to create and preview ratio images of twobands (Fig. 9). When the user enables this function, the programfirst captures two images at two specified bands and then calcu-lates the ratio image of the two acquired images. The ratio imageis scaled to [0-4095] (12-bit) and displayed in the image preview

Fig. 7. The mosaic image of a peeled onion at nine wavelengths (A) and the mean spectrspectra were extracted from the onion hyperspectral image collected by this program.

Fig. 8. The graphical wizard for setting wavele

window. The process is repeated continuously so that users canpreview the ratio image of the test object in real-time.

4.5. ROI and ensemble averaging

To enhance the usability of the system, the program also imple-mented two other functions: selection of region of interest andensemble averaging. The function ‘‘selection of region of interest’’enables the user to select a rectangular ROI on the image for pre-viewing or collecting images. It allows the user to collect the dataonly on the ROI and hence reduces the size of the collected spectralimages. The function ‘‘ensemble averaging’’ was implemented forthe applications requiring a high signal to noise ratio. When thisfunction is enabled, the program takes multiple scans at eachwavelength based on the scan number specified by the user, andthen uses the averaged image as the output data of the wavelength.These two functions can be applied in both hyperspectral and mul-tispectral image acquisitions.

a of the body and neck scales of the onion from 950–1650 nm (B); both images and

ngths of multispectral image acquisition.

Page 8: Development of software for spectral imaging data acquisition using LabVIEW

Fig. 9. The user interface for previewing 2-band ratio images of the test object. The onion had bacterial infection on the neck area, which was shown as a white area on theratio image (1050/1400 nm).

W. Wang et al. / Computers and Electronics in Agriculture 84 (2012) 68–75 75

5. Summary

This paper demonstrates the design and implementation of dataacquisition software for an LCTF-based spectral imaging system.The module-based architecture and the use of FSM design patternenables the flexibility, reusability, and expandability of the pro-gram. Using this program, the LCTF-based spectral imaging systemcan be used to flexibly acquire hyperspectral, multispectral, andcolor images. The usability of the system was enhanced by severaladvanced features, such as previewing band ratio images, selectingROIs, and ensemble averaging. In sum, this LabVIEW program metthe initial design criteria and can be applied to other LCTF-basedspectral imaging systems. The design strategies and techniquespresented in this paper can also be used to develop similar spectralimaging data acquisition programs.

Acknowledgements

This work was supported by the United States Department ofAgriculture National Institute of Food and Agriculture SpecialtyCrop Research Initiative (Award No. 2009-51181-06010). Theauthors acknowledge Dr. Chi N. Thai and Dr. Seung-Chul Yoon fordemonstrating their software programs. We also gratefully thankMr. Gary Burnham for his technical assistance in developing thissystem.

References

Bass, L., Clements, P., Kazman, R., 2003. Software Architecture in Practices, seconded. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.

Chang, C.-I., 2007. Hyperspectral Data Exploitation: Theory and Applications. Wiley-Interscience, Hoboken, NJ, USA.

Chen, C.H., 2008. Image Processing for Remote Sensing. CRC Press/Taylor & FrancisGroup, Boca Raton, FL, USA.

CRI, 2007. VariSpec Liquid Crystal Tunable Filters User’s Manual, md15474 rev, c ed.Woburn, MA, USA.

Denman, S., Lamb, T., Fookes, C., Chandran, V., Sridharan, S., 2010. Multi-spectralfusion for surveillance systems. Computers and Electrical Engineering 36 (4),643–663.

Evans, M., Thai, C., Grant, J., 1998. Development of a spectral imaging system basedon a liquid crystal tunable filter. Transactions of the ASAE 41 (6), 1845–1852.

Fischer, C., Kakoulli, I., 2006. Multispectral and hyperspectral imaging technologiesin conservation: current research and potential applications. Reviews inConservation 7, 3–16.

Gat, N., 2000. Imaging spectroscopy using tunable filters: a review. Proceedings ofSPIE 4056, 50–64.

Gebhart, S.C., Thompson, R.C., Mahadevan-Jansen, A., 2007. Liquid–crystal tunablefilter spectral imaging for brain tumor demarcation. Applied Optics 46, 1896–1910.

Jimnez, L.O., Vlez-Reyes, M., Hunt, S., Kaeli, D., Arzuaga-Cruz, E., Rosario-Torres, S.,Castrodad, A., 2011. Censsis solutionware: Hyperspectral image analysistoolbox. Available from: <http://www.censsis.neu.edu/software/hyperspectral/hyperspectral.html> (Retrieved 10 Nov, 2010).

Kim, M.S., Chen, Y.R., Mehl, P.M., 2001. Hyperspectral reflectance and fluorescenceimaging system for food quality and safety. Transactions of the ASAE 44 (3),721–729.

Lerner, J.M., Drake, L.A., 1999. Hyperspectral imaging in a LabVIEW environment.Proceedings of SPIE 3605, 264–272.

Lu, R., Chen, Y.-R., 1998. Hyperspectral imaging for safety inspection of food andagricultural products. Proceedings of SPIE 3544, 121–133.

Martin, M.E., Wabuyele, M.B., Chen, K., Kasili, P., Panjehpour, M., Phan, M., Overholt,B., Cunningham, G., Wilson, D., Denovo, R.C., Vo-Dinh, T., 2006. Development ofan advanced hyperspectral imaging (HSI) system with applications for cancerdetection. Annals of Biomedical Engineering 34 (6), 1061–1068.

Schwartz, S., 2005. Spectral imaging evolves to meet biomedical needs. Laser focusworld 41 (5), 87–91.

Singh, C.B., Jayas, D.S., Paliwal, J., White, N.D.G., 2010. Identification of insect-damaged wheat kernels using short-wave near-infrared hyperspectral anddigital colour imaging. Computers and Electronics in Agriculture 73 (2), 118–125.

Sun, D.-W., 2010. Hyperspectral Imaging for Food Quality Analysis and Control.Academic Press, Elsevier Science & Technology, Burlington, MA, USA.

Wagner, F., Schmuki, R., Wagner, T., 2006. Modeling Software With Finite StateMachines: A Practical Approach. Auerbach Publications, Boca raton, NY, USA.

Wang, W., Li, C., Tollner, E.W., Rains, G.C., Gitaitis, R.D., 2011. A liquid crystaltunable filter based shortwave infrared spectral imaging system: designand integration. Computers and Electronics in Agriculture http://dx.doi.org/10.1016/j.compag.2011.07.012.

Williams, P., Geladi, P., Fox, G., Manley, M., 2009. Maize kernel hardnessclassification by near infrared (NIR) hyperspectral imaging and multivariatedata analysis. Analytica Chimica Acta 653 (2), 121–130.

Williams, R., 2006. Real-Time Systems Development, first ed. Butterworth-Heinemann, Burlington, MA, USA.

Yoon, S.C., Park, B., Lawrence, K.C., Windham, W.R., Heitschmidt, G.W., 2011. Line-scan hyperspectral imaging system for real-time inspection of poultry carcasseswith fecal material and ingesta. Computers and Electronics in Agriculture 79(2), 159–168.