CoverageTool (‘Coverage.exe’) is an interactive graphical WIN32 application written in C++ (Visual Studio 2008 Express Edition). There are no LINUX or IOS versions.
The application accepts 24-bit BMPs as input and allows assessment of foreground coverage selected by up to 10 different shades, while other up to 10 different shades can be designated background and ignored. The application displays the original image—and an image in which the background has been erased—side-by-side. The various foreground and background shades are defined by mouse-clicking the shades in the original image. The area of the foreground is calculated assuming that the BMP has correct embedded DPI information (which when converting a JPEG to BMP is usually the case).
CoverageTool enables the calculation of the percentage of coverage as well as area in cm2. There are some considerations that have to be taken into account while acquiring the images, and in some cases it is necessary to pre-process the images before using the CoverageTool as described below.
Image set acquisition and pre-processing
In all cases, open your image using MSPaint, and then save it as a 24-bit BMP file.
For relative area coverage calculated as percentage, the uniformity of the set image acquisition is highly important. When capturing images, the same settings must be applied throughout, especially the distance from the object. Otherwise, it would be necessary to include in the image an object of known dimensions, which will enable the standardization of the dataset during pre-processing. For example, a petri dish borderline was used as common scale and cropped in accordance using MSPaint’s ‘crop’ function (Fig. 1).
It is possible to include number of separate samples on the same sheet (each time erasing all but one and analyzing it). CoverageTool ‘Coverage.exe’ software and instructions for use-are found in Additional files 1, 2, 3 and 4.
Quality control: To demonstrate CoverageTool’s ability to correctly calculate areas, an ‘A4 square-pattern’ sheet where 4 squares equals 1 cm2, was scanned. All but a 2 × 2 array of 0.5 cm squares was erased (Fig. 2a) and the white background was selected to be ‘ignored’. Finally we sampled the colors of the squared pattern paper to account as ‘coverage’ and calculated the area, which was indeed calculated by CoverageTool as equal to 1 cm2. Figure 2b shows calibration for a more complexed object of a known area of 4 cm2.
Color selection
Any image to analyze contains three parts.
Foreground: the items the relative coverage of which needs to be calculated, e.g. (green) canopy.
Background: the area not covered by canopy, e.g. bare soil.
Area to ignore: patches of the image which obscure/do not contain either foreground or background, (foreign objects) e.g. sample label or netting.
CoverageTool provides the user with the ability to define custom color datasets by “sampling” pixel colors from the image to cover the range of colors in the measured object area. Pixels ‘close’ to one of the specified colors according to a RGB or YCbCr metric (within user-specified tolerance) are considered part of the measured object, while pixels ‘further’ away are considered as background. In the same manner the user may sample pixels to ignore, which are not part of the measured object and not part of the background—but are present in the image.
In order to achieve the best representation of the dataset, the process of color sampling should be applied for a number of images, representing the extremities of the entire dataset (each time improving the selection and saving it). Once color selection has been optimized, it can be later applied to the entire dataset in a uniform manner.
Changing the tolerance level determines the ‘closeness’ of pixels in the image to one of the colors specified in the custom dataset according to an RGB or YCbCr metric and has a dramatic effect on the analysis. The same tolerance level must be applied to the entire set to ensure uniformity.
Calculations
Let N be the number of pixels in the image, let C be the number of pixels that were near to one of the selected colors to include, and let I be the number of pixels that were near to one of the selected colors to ignore.
The coverage percent (Foreground) is: (C × 100)/(N − I)
If B is the number of background pixels, then B = N − C − I
Thus the coverage percent (Foreground) is also: (C × 100)/(C + B)
The foreground area in cm2 is: C/(DPI/2.54) 2
The RGB or YCbCr color comparison metric selected must be applied uniformly across the entire dataset. Note that RGB requires higher color comparison tolerances. The YCbCr method deemphasizes the brightness of the pixel and concentrates on its hue.
The RGB algorithm assesses the similarity of colors using the differences of the RGB components of the pixel in the picture (rgb1)—and the reference pixel mouse-clicked (rgb2):
$$\left( {{\text{r1 }} - {\text{ r2}}} \right)^{{\text{2}}} + {\text{ }}\left( {{\text{g1 }} - {\text{ g2}}} \right)^{{\text{2}}} + {\text{ }}\left( {{\text{b1 }} - {\text{ b2}}} \right)^{{\text{2}}} < {\text{ tolerance}}^{{\text{2}}}$$
In the YCbCr algorithm, RGB values are converted to YCbCr (Y is the luminance or brightness and Cb and Cr are color components) and the similarity of colors is assessed by:
$$\left( {{\text{Cb1 }} - {\text{ Cb2}}} \right)^{{\text{2}}} + {\text{ }}\left( {{\text{Cr1 }} - {\text{ Cr2}}} \right)^{{\text{2}}} + {\text{ }}\left( {{\text{Y1 }} - {\text{ Y2}}} \right)^{{\text{2}}} /{\text{ 9 }} < {\text{ tolerance}}^{{\text{2}}}$$
The same tolerance is applied to all selection channels.
Instructions
Instructions to use CoverageTool can be found also in Additional files 2 and 3. After preparation of the dataset as described, run the program ‘Coverage.exe’. CoverageTool (Additional file 1).