In situ determination of soil colour using consumer-grade digital imaging equipment and open-source based image processing

Protocol

Authors

Emmanuel Bourdon, Jean-Luc Maeght, Alain Pierret, Olivier Ribolzi

Overview

Colour is one of the most obvious characteristics of soil. It provides insight into the soil composition and its physico-chemical environment. This protocol describes the acquisition of images of soil surface in situ using a digital camera attached to a hand-held micrometerscope. In addition the protocol explains how such images can be used to derive numerical values of soil colors, in different color spaces, which provides the basis for objective and convenient comparisons between treatments.

Background

Soil colour is closely related to the nature and abundance of some of its constituents (Schwertmann, 1993), in particular, oxides (Torrent et al, 1983), organic matter (Lindbo et al. 1998) and water content (Bedidi et al 1992, Person 2005). In addition, it provides clues to the conditions that the soil is subjected to, in particular, it reflects land use and is as such a variable of interest for agronomic diagnostic. The Munsell® colour book is classically used to describe soil colour (Munsell Color Compagny, 1994). Such a visual determination has several disadvantages: it is inherently subjective (Mellville and Atkinson, 1985) and there is only a limited number of standard colour categories which greatly restricts the possibilities of numerical and statistical analysis. With the recent advent of digital imaging it has become possible to measure soil colour accurately using readily available consumer-grade digital cameras (Viscarra Rossel et al. 2008; Levin et al. 2005). This protocol was developed in the laboratory under controlled light conditions and subsequently adapted to field conditions using a portable light source enclosed in a dark chamber.

Materials/Equipment

  • Digital Camera: Canon Powershot A640.

  • Sugitoh micrometerscope TS-8LEN-50 equipped with a LED ring around the lens (powered by TS-8L-LCC battery box with built-in dimmer) and a TS-8L-DGA Universal digital camera adapter.
  • A set of four AA batteries. .
  • A dark chamber made out of PVC pipe 53 mm in inner diameter, 60 mm in length, painted in mat black.
  • The ImageJ and R software packages.

Units, terms, definitions

  • RGB values: an additive color model in which red (R), green (G), and blue (B) are added together in various ways to reproduce a broad array of colors.
  • Munsell coordinates: a color space that specifies colors based on three color dimensions: hue (H), value (V; lightness), and chroma (C; color purity).

Procedure

I – Device setup

The digital camera is attached to the micrometerscope using the universal digital camera adapter. The dark chamber is fixed to the end of the micrometerscope. This assembly is connected to the battery box with built-in dimmer (Figure 1)

Figure 1. Imaging device set up. 1.digital camera, 2. Sugitoh universal digital camera adapter 3. Sugitoh TS-8LEN-50 micrometerscope, 4. dark chamber, 5. battery box with built-in dimmer.

II – Imaging settings

The camera is used in “Manual” mode with the following settings:

  • Focal length: 7 mm
  • Shutter speed: 2.5 sec.
  • Lens aperture: F/2.8
  • Flash mode: off
  • Exposure compensation: 0 EV
  • ISO setting: 100
  • White balance: Cloudy
  • Color representation: sRGB
  • Image size: 640 x 480 pixels

Lighting is adjusted using the dimmer on the battery box, so that the metered exposure results in a 0 EV value (Half press the shutter to see the metered exposure on the camera’s LCD display). To limit undesirable image features such shadows, specular and diffuse reflections related to soil micro-relief, shots are taken out of focus by adjusting the focusing ring of the micrometerscope. Between 10 and 20 digital photographs are taken for every 1m2 of soil surface to be analyzed.

III – Associated soil sampling

For comparison purposes, photographs must be taken under the same conditions of soil moisture. If not, soil moisture must be determined gravimetrically. Therefore, for every 1m2 of soil surface to be analyzed, it is strongly advisable to collect at least 3 replicate soil samples for subsequent determination of soil water content. Depending on the purpose of the soil color analysis, soil samples can also be taken for further physical and chemical analyses.

IV – Manual extraction of RGB values from the digital shots and visualization

The field-of-view of digital shots through the micrometroscope is circular and has an actual diameter of 3.6mm (Figure 2). Image measurements are performed on an area consisting of 1,877,179 pixels. These images are taken in RGB mode (Red, Green and Blue).

Figure 2. Typical example of an image.

The ImageJ software is used to derive the average RGB values of images taken with a digital camera. First, select the “Analyze -> Set Measurement” menu and tick “Area”, “Standard Deviation”, “Min & Max Gray Value” and “Mean Gray Value”. Then, select “Plugins -> Analyze -> Measure RGB” which displays in a “Results” window the mean, standard deviation, minimum and maximum values of R (Red), G (green) and B (blue) in the analyzed image. These values can be saved as a Microsoft Excel file by selecting “File -> Save as” (version used: Microsoft® Office Excel 2003) . The resulting file is rearranged in Excel, by selecting “Data -> Pivot table” so as to produce a first file in which average R, G and B values of each individual digital shot are recorded in separate columns (Figure 3).

Figure 3. Rearrangement of ImageJ output file in Microsoft Excel. a) Output text file produced by ImageJ imported in Excel; b) Re-arrangement using Excel’s Pivot Table Wizard; c) Result.

For visualization purposes, three additional files can be produced: the first one containing only the average R values of each individual shot, the second only the average G values and the third, only the average B values. Each of these individual files is then saved as a .txt file under Excel and subsequently imported as a text image in ImageJ using the “File -> Import -> Text Image” menu. These text images being very small in size, use the “Image -> Zoom -> in” function to visualize them. Each of the text images must be converted to 8-bit format using the “Image -> Type -> 8-bit” menu. Images corresponding to each of the R, G and B channels are combined as a single “stack” by selecting “Image Stacks Images to stack” and then “Image Color Stack to RGB “. The result is a RGB color image in which each pixel represents the average RGB colour of original digital shots of the soil surface. The ImageJ plugin “Color inspector 3D” (found under “Plugins Color Color inspector 3D” – yle type=”text/css”> To be downloaded from http://imagej.nih.gov/ij/plugins/color-inspector.html) provides a means to inspect the raw colour values using a range of colour spaces, using the “Colour space” scrolling button. A simple statistical analysis (frequency histogram) of each colour image is available under the heading display mode. The percentage of the colour images is represented by spheres of different diameters. These spheres are positioned in a Cartesian coordinate system in three dimensions (Figure 4).

Figure 4. Example of visualization of uncalibrated colours in the Munsell colour space using the ImageJ plugin “Color inspector 3D”.

V – Automatic extraction of RGB values from the digital shots

Provided that images are consistently taken using the same parameters – in particular the same geometrical arrangement – an ImageJ macro (“BatchRGBMeasure” see appendix 1) can be used to derive the RGB values automatically. For this purpose, images must be stored in a given directory (variable “dir”) and a second directory (variable “OutDir”) must be created to store the result file. This result file is formatted as follow: every row contains the file name (which must be indicative of location and date of image acquisition), followed by the average value for the Red, Green and Blue channels (Figure 5). Note that only the part of the image that contains soil colour data must be measured. The size and location of the image region (or Region Of Interest – ROI) to be measured must be adjusted as needed, depending on shooting conditions.

Figure 5. Example output file of the”BatchRGBMeasure” ImageJ macro.

VI – Conversion of RGB values into calibrated Munsell colours

RGB values measured using the micrometerscope+camera system can be converted into Munsell colours using a second ImageJ macro, “Get_RGB_Munsell” (see appendix 2), similar to “BatchRGBMeasure”, but designed to fetch reference RGB values from original plates of the Munsell colour code. To this purpose, colour “stamps” of pages of interest from the Munsell colour code must be imaged using the micrometerscope+camera system and the corresponding RGB values stored in a table (Figure 6). By compiling several pages of the Munsell colour code it is therefore possible to generate a reference table or LUT (Look Up Table) against which any image can be compared (Figure 7).

1. 2.

Figure 6. 1.A reconstituted page of the Munsell colour code based on the information stored in the text file produced by “Get_RGB_Munsell” and 4. an example output of the “Get_RGB_Munsell” macro.

Figure 7. Extract from the LUT generated using “Get_RGB_Munsell”, based on which it is possible to relate RGB values measured using the scanning system to Munsell Hue, Chroma and Value (H,V, C).

Finally, a R source – “ProcessColl” (appendix 3) – is used to open the text file that contains results from the ImageJ macro “BatchRGBMeasure” and compares every RGB triplet stored in the file to the RGB/Munsell reference LUT. The comparison is achieved by computing, successively, every Euclidean distance between the RGB triplet under consideration and the RGB triplets stored in the reference LUT. It is assumed that the shorter this distance the more likely the correspondence between a given sample and a reference value. Based on this assumption, the output of “ProcessColl” consists of a table where data relative to the location and date of image acquisition are stored against what can be considered as the most probable Hue Value and Chroma in the Munsell colour space, see example in Figure 8.

Figure 8. Example output file of the “ProcessColl” R source code.

VII – Results interpretation

The use of a darkroom between the soil surface and the micrometerscope allows keeping control over color balance and exposure under variable ambient lighting conditions that prevail in the filed (direct sunlight, shadows, reflections etc…). The ImageJ software offers a convenient means to derive average RGB values from pictures of soil surface taken in the field and subsequently transform them into Munsell color codes. Such values can then be used, in conjunction with soil analyses, to interpret the effect of e.g. land use or cultural practices on variations of soil properties such as Soil Organic Carbon, iron or manganese oxides, soil moisture etc… Once the color-soil property relationships validated, the analysis of soil color can be used as a simple and affordable proxy for agronomic diagnostic.

Other resources

– Reference information about the imageJ macro language is available from: http://rsb.info.nih.gov/ij/developer/macro/macros.html or downloaded from:http://rsb.info.nih.gov/ij/docs/macro_reference_guide.pdf(external link)

– An introduction to the R language is available from:http://cran.r-project.org/doc/manuals/R-lang.html(external link) orhttp://en.wikipedia.org/wiki/R_(programming_language(external link)) or downloaded fromhttp://cran.r-project.org/doc/manuals/R-intro.pdf(external link)

Notes and troubleshooting tips

Prior to any field observation, ensure that batteries used for the light source are new or fully charge. It is strongly recommended to always have a spare set handy. To ensure consistency of soil moisture conditions, the surface to be photographed can be saturated with water using a sprayer. Please note that pieces of ImageJ and R code provided as appendices to this protocol are only provided as examples that must to be adapted to specific user’s needs and are not meant to work readily on any computer platform or file system structure. They were successfully used with IJ 1.34s on MacOSX 10.4.9 with Java 1.5.0_07 and IJ 1.36b with WinXP v2002 SP2 with Java 1.5.0_06 and R.app GUI 1.35 (5632) with i386-apple-darwin9.8.0 but may not work with different versions of the softwares. IMPORTANT: Please note that double antislash “\” is the required separator to specify file paths in Microsoft Windows (not the “/” used in the examples). DISCLAIMER: the ImageJ and R macro code included in this protocol is provided “as is” with ABSOLUTELY NO WARRANTY from the Contributors. In no event shall the Contributors be liable for any direct, incidental, special, exemplary, or consequential damages (including, but not limited to loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this code, even if advised of the possibility of such damage.

Links to resources and suppliers

Literature references

Bédidi A, Cervelle B, Madeira J, Pouget M 1992. Moisture effects on visible spectral characteristic of lateric soils. Soil Science Society of America Journal, 153, 129-141.

Levin N, Ben-Dor E, Singer A 2005. A digital camera as tool to measure color indices and related properties of sandy soils in semi-arid environnement. International Journal of Remote Sensing, 26 (24), 5575-5492.

Melville M D, Atchinson G 1985. Soil colour: its measurement and its designation in models of uniform colour space. Journal of Soil Science, 36,495-512.

Munsell Color Compagny 1994. Munsell Soil color Charts, Revised edn. Macbeth Division of Kollmorgen, New Windsor, NY.

Persson M 2005. Estimating surface soil moisture form soil color using image Analysis. Vadose zone J. 4, 1119-1122.

Schwertmann U 1993. Relation between iron oxides, soil color, and soil formation.p.51-59. In Soil Color. Soil Sci. Soc. Am. Spec. Pub. 31.

Madison, WI. Torrent J, Schwertmann U, Fechter H and Alferez F 1983. Quantitative relationships between soil color and hematite content. Soil Science 136 (6):354-358.

Viscarra Rossel R A, Fouad Y, Walter C 2008. Using a digital camera to measure soil organic carbon and iron contents.

Health, safety & hazardous waste disposal considerations

Do not stare at the high brightness LEDs of the TS-8LEN-50 LED ring , as doing so may cause permanent damage to your eyes.

Regarding the safe use of digital camera equipement, refer to the manufacturer’s health and safety recommendations

Appendices

 

Leave a Reply