Example code for implementing contrast stretching and segmentation in Excel.
Microsoft Excel was recently added to the list of software applications for signal and image processing. The use of Excel as a powerful tool for teaching signal and image data processing techniques as demonstrated in agriculture and natural resource management can be easily adopted for biomedical applications. In the same vein, Excel’s proven utility as a research tool can also be harnessed. This chapter expands the methodology of signal and image formation, visualization, enhancement, and image data fusion using Excel. Different types of techniques used in biomedical imaging are introduced, including: X-ray radiography (X-rays), computerized tomography (CT), ultrasound (U/S), magnetic resonance imaging (MRI), and optical imaging. However, the chapter mainly focuses on optical imaging involving a single spectrum or multiple spectra such as RGB. Specific illustrations of corresponding outputs from different techniques are discussed in the chapter for a better appreciation by the reader.
- optical imaging
- multispectral imagery
- image visualization
- image enhancement
- RGB image data
Biomedical signal and digital image processing pertains to the manipulation of signal and image data to obtain output images that are useful for human health diagnostics and therapeutic purposes. This may range from the capture of a static image of the condition of an organ or tissue to the capture of multiple images at different stages of a condition to monitor the physiological process of development. It involves using different approaches for visualizing biological tissues, altogether aimed at improving health. Related research efforts lead to the development of better diagnostic tools in clinical settings as well as the improvement in developing appropriate drugs and other therapies.
Different types of techniques are used in biomedical imaging including X-rays , computerized tomography (CT) , ultrasound (U/S) , magnetic resonance imaging (MRI), and optical imaging. The scientific and engineering principles and technology underlying these techniques and associated sensors, instrumentation, and software continue to evolve [1, 4]. This has led to more accessibility to healthcare involving these techniques and associated technologies.  provided a survey of current commercial implementations and identification of essential differences and similarities in image and signal processing approaches. The fundamentals of biomedical image processing including terminology used and imaging modalities are presented by . The need to obtain high quality images of diagnostic and therapeutic relevance remains at the heart of the practice. Both high-level and low-level image processing and visualization are of great significance. While high-level image processing and analysis as programmed in a given biomedical device may not be directly applicable to other needs, low-level processing and analysis can be used for research and development and/or teaching purposes to explore other possibilities. Also, despite the fact that computation approaches may differ, the output images similar purposed approaches may yield similar outputs.
Researchers in medicine and biomedical science and engineering often utilize spectroscopic techniques for research and clinical purposes. Measurements in the ultra-violet, visible, and near infrared wavelength ranges are performed for different medical and biomedical applications. The use of fiber optic based spectrometers allow for in vivo measurements and testing procedures that are inexpensive and disposable. The generation of diagnostic information based on processing and analyzing digital signal and imagery obtained from such techniques has also been applied in other disciplines including agriculture , biology , and geography at different spatial scales.
Digital imagery consists of dual-dimensional arrays (rows and columns) of square pixels having values that represent signal intensities captured by the imagery sensor’s detector . The imagery sensor may operate in a single band (monochrome) on the electromagnetic spectrum or in multiple bands (multispectral) which may be contiguous or discrete. The pixel values of a monochrome (8-bit) image have a range of 0 to 255 (i.e., 256 colors). Multispectral image data consisting of three bands are fused to obtain color images with 16,777,216 (i.e., 256 × 256 × 256) possible colors. True color or RGB images such as are obtained by commercial digital cameras consist of data from the red (R), green (G), and blue (B) bands of the visible portion of the electromagnetic spectrum. In certain applications, different images can be layered on top of each other to give composite images containing details not found in a single image.
Several software applications have been commonly known for their use in performing low-level image processing and analysis. However, until recently, Microsoft Excel was not recognized for such utility although it had been attempted in the works of [9, 10, 11] and shown to have some potential.  utilized a Visual Basic for Applications (VBA) macro program for visualizing terrain image data. They determined that its function and quality were similar to a typical geographic information system (GIS). However, some macros do not work properly when used in versions of Excel other the versions used to create them.  also developed a clustering approach in Excel based on k-means algorithm. They made use of an Excel add-in called “loadImageArray” in acquiring RGB data from images. Likewise,  developed an Excel 2007 add-in known as “Image Manipulation”, which can extract data (decomposed into R, G, and B data in separate workbooks) from a JPEG image, resize the image to fit the available number of columns, and export it back as JPEG images. After properly saving a required library file, the “Image Manipulation” add-in runs smoothly in later versions of Excel. It is possible to further manipulate the data using either the add-in’s programmed methods or Excel’s features. In view of the above examples, one of the major limitations for using Excel for image processing and analysis has been how to make the image data available in Excel ‘painlessly’. Now, image data can be extracted via  and copied to an Excel workbook for processing and analysis.
Recently, several publications of Larbi and colleagues have extensively demonstrated the utility of Microsoft Excel for image processing and analysis. First was a study which demonstrated similarities in processed data from images captured using different cameras . Image data were extracted into Excel using the RGBExcel application . The RGBExcel application was further improved as a new version called RGB2X, which provides several advantages over the RGBExcel including the ability to extract data from multiple image files at once into corresponding Excel workbooks . An extensive demonstration of applying the methods of image processing and analysis is presented in  and further expanded in . The Excel based methodology was useful in demonstrating the potential use of time-lapse cameras in studying changes in condition over time [6, 18]. It was also useful in determining the optimal timing for cover crop termination to control weeds while maintaining good soybean yields . Although the examples demonstrated are mainly agricultural examples, it is well understood that the methods of image processing are broadly applicable and of interdisciplinary importance.
As such, based on the potential of using Microsoft Excel for processing and analyzing digital images as shown in previous literature, the main aim of this chapter is to demonstrate the potential use in biomedical optical imaging applications. Specific illustrations of corresponding outputs of different visualization, and image enhancement, and image data fusion are provided for a better appreciation by the reader.
2. Processing and analyzing biomedical images
For simplicity, image processing and analysis is discussed as an integrated methodology rather than separate steps or one being a subset of the other. Biomedical digital image processing generally implies using computers to manipulate digital image data pertaining to biomedical sciences to output other images possessing diagnostic information. Image analysis encompasses the entirety of steps used for quantitative assessment and abstract interpretation of biomedical images. Image processing and analysis includes a number of processes that adjust contrast and brightness, assist in distinguishing between different tissues, and others that perform measurements or assess the rate of development of certain processes.
Overall, the steps can be outlined as: image formation, visualization, enhancement, analysis, and interpretation. These steps and their order are not conclusive but suggestive as the specific order depends on the images being processed. For instance, different image enhancement techniques can be applied at different stages of image processing and analysis. For high-level analysis of automated systems, the appropriate steps are incorporated into algorithms with preset parameters for the target images. Such steps require a priori knowledge of the basic features and constitution of the images, and the algorithms typically cannot be directly transferred to other applications.
This chapter focuses on simple and commonly used methods for processing optical images such as for enhancing images prior to additional digital analysis and/or visual interpretation. The use of Excel in implementing the various image processing steps are demonstrated in the following sections. The general procedure used in Microsoft Excel for implementing these different image processing methods are outlined as follow: (1) creating a new (blank) output worksheet; (2) applying the method’s formula to the upper left cell, i.e. A1, utilizing the original R, G, and B data; and (3) copying the formula to apply to the rest of the cells up to the extent of the original data. The original data is therefore preserved in the processing.
3. Image formation
Image formation encompasses all the necessary steps from image capture to creating a digital matrix of pixels. With the purpose of using Microsoft Excel for image processing, image formation also includes making the image data available in Excel. These are discussed further in sub-sections 3.1 and 3.2.
3.1 Acquiring digital images
Optical medical images can be obtained using a number of optical devices including endoscopes in their different kinds such as bronchoscopes, colonoscopes, and laparoscopes that allow physicians and clinicians to view inside various channels of anatomic tubes. Examples of such channels include the bronchial system, the gastrointestinal tract, and the genitourinary system. An extended list of the different types of endoscopes and their uses is provided by . Endoscopic diagnostic procedures use a guided probe based system with a camera and lighting for imaging. More details on the procedures including pre-procedure preparation and post-procedure expectations can be accessed in .
Different materials reflect incident light differently. Measurements of light reflectance (proportion of incident light that is reflected) by different materials such as the human skin and internal tissues can unveil great amounts of diagnostic information about their conditions. An example of this kind of measurement is the use of a dermal auto-fluorescence measurement for detecting advanced glycogen end products (AGEs) in patients . Near-infrared measurements of deep tissue reflectance is also useful for assessing the effectiveness of radiation therapy as decreasing cancerous masses. Such measurements depend on spectroscopic analysis including image processing.
Cameras or imaging systems such as discussed above output RGB or RGB-type images. For the purpose of demonstrating potential applications, image acquisition using common devices such as digital cameras and cellphones is also considered for capturing external parts of the human body to assess variability in skin condition resulting from disease or exposure to certain extreme environments. Examples of such targets include healthy skins, skins with sunburn, facial skins with acne, and skins showing different stages of a disease.
For the purpose of demonstration in this chapter, images were acquired from . The scales of these images are uncertain. However, this does not diminish their usefulness for demonstration purposes. Figure 1 shows images of tissues with various conditions: (a) eczema atopic dermatitis symptom skin; (b) allergic rash dermatitis eczema skin; (c) psoriasis vulgaris skin; and (d) colon affected by ulcerative colitis.
3.2 Image digitization
Regardless of file format, image data from the R, G, and B bands can be extracted from images to Microsoft Excel using the RGB2X software application [13, 17, 24]. The extracted data are populated in different worksheets and named accordingly. Figure 2 shows worksheet tabs corresponding to R, G, and B band data, with a section of the G band data displayed. The UC worksheet originally has three adjacent columns having sequentially unidimensional R, G, and B datasets. This allows for certain analyses like histogram and clustering to be accomplished. Alternatively, the image data can be extracted by  and uploaded into Excel.
4. Image visualization
Various chart options in Microsoft Excel can be used to visualize the image data once the data are available in Excel. With the desired dataset selected, the appropriate chart option can be accessed via the INSERT Ribbon. [16, 17] identified the 3D surface and contour as the preferred or effective depictions of the two-dimensional image data of the R, G, and B bands and further processed data. Both charts have a spatial dimension of 255 categories on the x-axis and 255 data series on the y-axis, and a spectral dimension of 256 pixel values (i.e. 0–255 gray levels) on the z-axis for the 3D surface chart. The pixel values (signal intensities) are displayed as different colors in the contour chart. However, in order to reduce the dimensionality of the data and the complexity of image processing, the 256 pixel values are displayed in only a few colors. However, once features in the image have been identified, the data can be further processed to reduce its dimensionality.
The one-dimensional datasets of the R, G, and B band which are shown in the UC worksheet in Excel and their derived datasets can be visualized in two ways. First, histograms of each dataset can be obtained utilizing the Data Analysis ToolPak. The Data Analysis ToolPak is an optional add-in tool in Excel. Second, similarly as described in the preceding paragraph, the X Y (scatter) chart can be accessed to produce cluster plots of any two datasets (columns). This can be useful for feature extraction and unsupervised classification purposes.
Figure 3 shows 3D surface charts, contour charts, and histograms (rows 1, 2, and 3, respectively) of R, G, and B band data (columns 1, 2, and 3, respectively) from Figure 1a. The 3D surface and contour charts were set to display only six colors with the data range. These charts show variations in the skin condition, however, the features are not very well separated. Also, as expected, the nature of the data is clearly different among the three bands due to differences in signal responses of different features.
5. Image enhancement
Image enhancement methods can be applied to biomedical image data to more effectually render the data for subsequent analysis and interpretation. The selected algorithm may manipulate: the contrast of a single image; the data of multiple images at the same time; or the spatial features in an original or derived image . The output image data tends to have intensified visual distinctions that are useful for both digital and visual analyses. As already mentioned, applying image enhancement operations in Excel requires a new output worksheet for resampling, in which the appropriate formula is applied to one cell and then copied to additional cells within the dimension of the original data. The original source data worksheets are retained and referenced in entering the formulas. The procedures used to implement these enhancements have been exemplified in [16, 17].
5.1 Contrast manipulation
Three different forms of contrast manipulation are segmentation (a.k.a. gray level thresholding), level slicing, and contrast stretching. Segmentation generally connotes the division of an image into typically two contiguous regions , e.g. foreground versus background. The division is based on a threshold value identified to separate the levels appropriately. Different contrasting colors are assigned to the different classes. The algorithm is extended to obtain more than two levels using multiple threshold values (one less the number of classes), what is termed as level slicing. This could imply splitting an image into various diagnostically and therapeutically relevant areas, for instance, differentiating between anatomically healthy tissues and infected tissues at multiple levels. Thus, segmentation (or level slicing) can be considered as a pre-stage of image classification. It can be used to classify different features including raw pixels, edges, textures, and so on. On the other hand, contrast stretching is applied to image data to spread the data across the full range of 256 gray levels.
Figure 4 provides example contrast manipulation outputs of Figure 1b which portray different depictions of allergic rash dermatitis eczema on a human skin. Figure 4a is a segmented contrast stretched B band image where the eczema symptoms are shown as the foreground and the clear skin as the background. Figure 4b shows a five-level sliced R/G ratio image where the lowest level (lightest gray) represents clear skin while the subsequent darker grays indicate different severities of the symptoms. Multi-image manipulation operations such as the simple ratio of R data on G data are discussed in Section 5.2. Figure 4c is a fused contrast stretched false color RGB image where contrast stretching was applied to all three datasets before fusion. Figure 4d is a fused contrast stretched monochrome R band image.
To obtain the output in Figure 4a, the B band data (min = 2; max = 203) was first stretched to fill a range of 0–255 by using the corresponding function code in Table 1. Then, the data was split into two arbitrary values (0.3 and 0.8) for display based on a threshold value of 150 using the corresponding function code in Table 1.
|Operation||Function code in cell A1 of output worksheet|
The output of Figure 4b was accomplished by first obtaining a simple ratio data (min = 1.1; max = 6.8) of R band pixels on G band pixels (simple ratios are discussed in Section 5.2) and then slicing them into five arbitrary values (0.1, 0.3, 0.5, 0.7, and 0.9) for display based on four threshold values of 1.2, 1.4, 1.8, and 2.2. The function codes are shown in Table 2.
|Operation||Function code in cell A1 of output worksheet|
|Simple ratio (R/G)||='R'!A1/G!A1|
Figure 4c was obtained by implementing contrast stretching separately to R band data (min = 123; max = 255), G band data (min = 18; max = 224), and B band data (min = 2; max = 203) and then fusing the three datasets using a modified form of the Visual Basic for Applications (VBA) macro in the Appendix. A similar function code as in Table 1 was used to accomplish the contrast stretching here. Figure 4d was achieved by fusing just the contrast stretched R band data in triplicate (in place of R, G, and B) to obtain a monochrome image. Image fusion here was also accomplished by using a modified form of the VBA macro in the Appendix.
5.2 Multi-image manipulation
By its name, multi-image manipulation means manipulating data of more than one image together. Multispectral-band integrated enhancement techniques include spectral ratioing, integrating biological components, canonical components, and intensity-hue-saturation color space transformations. All these techniques have been discussed by [25, 26], and several others. [16, 17] demonstrated the implementation of spectral ratioing in Excel with an agricultural example. Here, we extend the demonstration with example applications in biomedical sciences.
Spectral ratioing enhancements are accomplished either by correspondingly dividing pixel values of one band by pixel values of another band as in simple ratios, or by dividing the pixel difference of corresponding cells in two bands by the sum of the same pixel values as for normalized difference ratios. These ratioing operations are effective for feature extraction from the image data. An example output image of a simple ratio between the R band pixels and G band pixels (R/G; indicated in Figure 3) is displayed in Figure 5. The image quantitatively shows the eczema atopic dermatitis symptoms on a skin as was seen in Figure 1a. The three areas of the skin showing symptoms indicate different severities. This demonstrates the effectiveness of spectral ratioing in distinguishing between biological tissues of different conditions. A similar output data which was subsequently level sliced to obtain quantitative measures of different severities of allergic rash dermatitis eczema on a skin was shown in Figure 4b. The ability to express such variations quantitatively can allow for more precise treatment.
Another example output of R/G spectral ratioing is shown in Figure 6 for the ulcerative colitis affected colon shown in Figure 1d. This results in identification of different tissues particularly capturing the colitis as white (Figure 6a). Figure 6b was obtained by further segmentation of Figure 6a data (min = 1.2; max = 14.3)) based on a threshold value of 2, where the colitis affected tissues showed pixel values less than or equal to the threshold value. The projected area of the image covered by colitis is approximately 21%, which was obtained as a ratio of the number of colitis infected pixels to the total number image pixels times 100.
5.3 Spatial feature manipulation
Examples of spatial feature manipulation techniques include edge enhancement, convolution, and spatial filtering. Edge enhancement methods attempt to achieve low frequency brightness information while at the same time preserving local contrast. These are obtained by combining the original pixel values with a high frequency component image of the same scene [25, 26]. The high frequency component can be created by spatial filtering which involves subtracting a convolved image from its original image. Convolution involves the use of an array of coefficients (e.g. 3 × 3 and 5 × 5) known as masks or kernels to apply a digital number to an output pixel corresponding to the central pixel of the original image. This can be implemented by simply finding the average or median  pixel value of the original image and entering that in the corresponding central pixel of the output image. The mask is moved to apply the operation throughout the original image to obtain the convolved image. Spatial filtering is done to emphasize or deemphasize image data of varied spatial frequencies (observed tonal variation roughness). Spatial filtering is a special case of convolution and is a pixel neighborhood operation. Figure 7 shows sequential enhancements of the data of the psoriasis vulgaris skin image which was shown in Figure 1c.
Figure 7a is the original image which is shown here again for ease of comparison. Figure 7b is an output image of R/G ratioing while Figure 7c is an edge enhancement applied subsequently. The edge enhancement was obtained by applying a multi-directional pixel differencing method to detect the edges. This was implemented by using a threshold difference value of 0.1 to create a binary data of, say ‘1’ for ‘edge’ if the absolute difference with at least one value of its neighboring four-directional pixels was greater than the established threshold value and or ‘0’ if otherwise  as in Table 3. It should be noted that the function code in Table 3 was applied to cell B2 and copied on only the remaining inner cells as only those are sounded by four neighbors. The function codes were modified for the outer cells (pixels). [28, 29] provide more details on multi-directional pixel value differencing. Figure 7d shows the output image of a 3 × 3 window convolution operation performed subsequent to the edge enhancement. Similarly to edge detection and for the same reason, the function code shown in Table 3 was applied to cell B2 and copied onto the remaining inner cells. Figure 7e was obtained as subsequent segmentation. Finally, Figure 7f is a true color RGB image with edge enhancement obtained by data fusion using the VBA macro in the Appendix.
|Operation||Function code in cell A1 of output worksheet|
|R/G Simple ratio (7b)||='R'!A1/G!A1|
|Edge detection (7c)||=IF(ABS(R_G!B1-R_G!B2)>=0.1,1,IF(ABS(R_G!A2-R_G!B2)>=0.1,1,|
Figure 8 demonstrates the implementation of spatial filtering in the G band data for the psoriasis vulgaris skin image shown in Figure 1c. Figure 8a is simply the fused image of the G data where only the G data was used for the R, G, and B components (see Appendix) to obtain a monochrome image output. This output image prior to the spatial filtering is not very sharp. Figure 8b was obtained after applying the spatial filtering. To accomplish this, the data was first convolved using a 3 × 3 window filter and the output data was subtracted from the original data. Finally, the result of the subtraction was added back to the original data. The final output image is edge enhanced and thus is sharper.
6. Further discussion on potential and limitation
The use of Microsoft Excel for implementing biomedical image processing and analysis methods as demonstrated in the preceding sections is a straightway possibility. This possibility is mainly because each blank worksheet acts as a fresh canvas where the cells are available for performing pixel by pixel computations or can be colored up to 16,777,216 colors based on RGB input data. Excel computations are also generally straightforward with some familiarity with entering formulas making use of common mathematical functions. Therefore, with the data available in Excel, already existing features and tools can be used to perform manipulations on the data. Further, as a general use spreadsheet program, Excel has a well-respected performance with data handling and now presents 2D and 3D graphing capabilities that are comparable to other image processing applications. Specifically, 3D surface and contour charts are two effective ways of visualizing the two-dimensional image data in Excel. These charts can be copied into other Microsoft Office Suite applications where they can further be directly formatted. This means that the final chart format does not need to be achieved in the Excel file. As an embedded chart in Word or PowerPoint, for instance, they can be shared between users and finalized later without requiring the original Excel file.
Although Excel does not currently have its own automated means of importing image data directly from an image file, the data can be copied from other resources such as . However, a more efficient means of acquiring the image data from multiple files all at the same time is by using the RGB2X 1.0 software application . RGB2X offers the advantages of multiple image file handling and creation of Excel files saved in the same location and having the same base name(s) as the original image file(s). Also, an additional worksheet in the Excel files having unidimensional forms of the R, G, and B data makes four data worksheets which can be used for performing certain analysis like histogram and clustering.
As a limitation, the RGB2X software application by design scales down images larger than 255 × 255 pixels during the data extraction process. This is to allow for viewing the data as charts in Excel. However, the reduced resolution may influence the quality of the raw and processed data. Also, solely using Excel’s standard features for image processing and analysis can retard the processing speed in high throughput applications. Furthermore, re-exporting RGB-type images of output data as standard image files is limited compared to advanced professional image processing software. Nevertheless, the limitations of Excel’s standard features and tools and that of re-exporting RGB-type images can be eliminated by including some VBA programming in Excel as depicted with image data fusion macro in the Appendix.
The potential use of Microsoft Excel for digital image processing and analysis was successfully extended to application in biomedical imaging. This potential depends on the ability to easily extract RGB data from a variety of image file formats into Excel which is now established by the use of the RGB2X 1.0 program. However, other resources including some being online may be used in extracting the data and copying into Excel. With the data being available in Excel, the possibilities of accomplishing a wide range of biomedical image processing and analysis in Excel combined with the use of Visual Basic in Applications (VBA) is unlimited. The selection of image processing and analysis methods demonstrated in this paper including the different image enhancement methods only serve as evidence of the enormous possibilities. Other methods would need to be tested in Excel covering a wide range of images captured using different biomedical imaging modalities. This should include using image metrics to compare Excel processed image data with processing based on other software platforms. Also, the limitations of reducing larger images for visualizing as charts in Excel would need to be addressed in future work. Finally, other aspects of image processing and analysis in Excel such as processing time requirement for completing different image processing tasks and image quality should be compared with other image processing software applications for increased understanding of the potentials and limitations of using Excel for biomedical image processing.
' RGBCells Macro
'SELECT SHEET TO OUTPUT TO
Dim myValue As Variant
myValue = InputBox("An output worksheet will be created. Type the exact name you want to use.", "Output Sheet Name", "RGB#")
Sheets.Add After:=Sheets(Sheets.Count) ‘Creates a new output worksheet
ActiveSheet.Name = myValue ‘Renames the output worksheet to user-specified name
Selection.ColumnWidth = 0.83 'Changes cell width to 10 pixels
Selection.RowHeight = 7.5 'Changes cell width to 10 pixels
ActiveWindow.Zoom = 15 'Zooms out
ActiveWindow.LargeScroll ToRight:= −1
ActiveWindow.LargeScroll Down:= −1
'FIND ROW AND COLUMN DIMENSION
Dim sht As Worksheet
Dim LastRow As Long
Dim LastColumn As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
LastColumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To LastRow
For j = 1 To LastColumn
Sheets("R").Select 'Switches focus to worksheet containing data for fusion as R
R = Cells(i, j) 'Assigns cell value as R value
Sheets("G").Select 'Switches focus to worksheet containing data for fusion as G
G = Cells(i, j) 'Assigns cell value as G value
Sheets("B").Select 'Switches focus to worksheet containing data for fusion as B
B = Cells(i, j) 'Assigns cell value as B value
Sheets(myValue).Select 'Switches focus to worksheet containing data for fusion as B
Cells(i, j).Select ‘Selects cell
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = RGB(R, G, B) ‘Applies RGB color to selected cell
.TintAndShade = 0
.PatternTintAndShade = 0