<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">OALibJ</journal-id><journal-title-group><journal-title>Open Access Library Journal</journal-title></journal-title-group><issn pub-type="epub">2333-9705</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/oalib.1103108</article-id><article-id pub-id-type="publisher-id">OALibJ-71512</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Biomedical&amp;Life Sciences</subject><subject> Business&amp;Economics</subject><subject> Chemistry&amp;Materials Science</subject><subject> Computer Science&amp;Communications</subject><subject> Earth&amp;Environmental Sciences</subject><subject> Engineering</subject><subject> Medicine&amp;Healthcare</subject><subject> Physics&amp;Mathematics</subject><subject> Social Sciences&amp;Humanities</subject></subj-group></article-categories><title-group><article-title>
 
 
  Facilitating the Automatic Characterisation, Classification and Description of Biological Images with the VisionBioShape Package for R
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Biel</surname><given-names>Stela</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Antonio</surname><given-names>Monleón-Getino</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Section of Statistics, Faculty of Biology, University of Barcelona, Barcelona, Spain</addr-line></aff><aff id="aff2"><addr-line>Statistics and Bioinformatics Research Group (GRBIO), Barcelona, Spain</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>amonleong@ub.edu(AM)</email>;</corresp></author-notes><pub-date pub-type="epub"><day>18</day><month>10</month><year>2016</year></pub-date><volume>03</volume><issue>10</issue><fpage>1</fpage><lpage>16</lpage><history><date date-type="received"><day>September</day>	<month>28,</month>	<year>2016</year></date><date date-type="rev-recd"><day>Accepted:</day>	<month>October</month>	<year>22,</year>	</date><date date-type="accepted"><day>October</day>	<month>26,</month>	<year>2016</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Here, we present the VisioBioshapeR package for R [R Core, 2014]. This new library is a comprehensive, multifunctional toolbox designed to automatically analyse biological images. The package extends other common libraries (Momocs, ShapeR) used for biological shape analysis by allowing the user to extract closed contour outlines automatically from reading binary images. Current functionalities of VisioBioshapeR include: random extraction of image coordinates, analysis of the shape of a biological image by the elliptic Fourier descriptor (EFD) method, extraction of an image characteristic vector using multivariate principal c
  omponent analysis (PCA) and geometrical analysis. The image vector of characteristics can be directly exported to a wide range of statistical packages in R and can be used to perform classification or other types of analysis in order to sort new images into classes. The package could prove useful in studies of any two-dimensional images and is presented with three examples of its application in ecology. The library is useful when multiple images are processed at a time and we wish to automate their analysis for example for recognition of images from patterns.
 
</p></abstract><kwd-group><kwd>Computer Vision</kwd><kwd> Biological Images</kwd><kwd> Ecology</kwd><kwd> Statistics</kwd><kwd> Elliptic Fourier Descriptor</kwd><kwd>  Principal Component Analysis</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Automatic identification of images, and biological images in particular (<xref ref-type="fig" rid="fig1">Figure 1</xref>), is a major area of current research where images are transformed into information that can be used later for image characterisation, classification or description. Currently it is a prominent subject with dozens of tools already developed in the field of biology, such as the study “ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations” [<xref ref-type="bibr" rid="scirp.71512-ref1">1</xref>] where the authors develop an R package to analyse otoliths morphometrically as a method to delineate fish stocks, characterise population movements and detect the natal origin of fish. Another example is “A tool for developing an automatic insect identification system based on wing outlines” where [<xref ref-type="bibr" rid="scirp.71512-ref2">2</xref>] developed a Matlab library to identify insects automatically based on wing outlines. Others techniques used for processing biological images can be found at [<xref ref-type="bibr" rid="scirp.71512-ref3">3</xref>] - [<xref ref-type="bibr" rid="scirp.71512-ref8">8</xref>] .</p><p>The principal image processing tasks involve several processes such as grey-level transformation, binarisation, image filtering, image segmentation, visual object tracking, optical flow and image registration. After acquiring image information, statistical techniques must be used for characterisation, classification or description, depending on the target. Image pattern recognition is the technique used to classify an input image into one of a set of predefined classes [<xref ref-type="bibr" rid="scirp.71512-ref1">1</xref>] . So the tasks of image processing can be divided into a feature extraction module and a statistical analysis module. We should emphasise here that a bio-image is a very difficult target even for state-of-the-art image processing and pattern recognition techniques, due to noise, deformations, etc., but unfortunately it is vital to have a suitable feature extraction module to permit good statistical analysis later on.</p><p>Here, we introduce VisioBioshapeR, an R package designed to analyse biological images automatically with a small number of easy-to-use functions (<xref ref-type="table" rid="table1">Table 1</xref>). There are built-in functions which allow users to perform automatic processes such as extracting the outlines from images, visualising the mean shape and transforming the outlines into independent coefficients using the result of principal component analysis (PCA) of the elliptic Fourier descriptor (EFD). The image vector of characteristics can be directly exported to a wide range of statistical packages in R and can be used to perform classification analysis or other types of analysis (cluster) in order to classify new images into classes.</p><p>The R library presented here is a general purpose library and resolves the problem of analysing numerous specimens at a time to recognise automatically biological images efficiently and within a reasonable time. As with the applications for identification of organisms, despite the existence of many image analysis applications, most free applications (SHERPA, ImageJ, Google’s Image Recognition Software) do not completely resolve the difficulty posed by biological imaging or processing, partly due to the variability and the large number of images needed to implement future automatic identification systems in biological imaging.</p><p>So, in this text, we present the mathematical basis for understanding the functions contained in the VisioBioshape library.</p><fig id="fig1"  position="float"><label><xref ref-type="fig" rid="fig1">Figure 1</xref></label><caption><title> Phase contrast image of diatoms from the inventory of the River Ebro (Spain)</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x2.png"/></fig><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> R functions available in VisioBioshapeR</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Function</th><th align="center" valign="middle" >Description</th></tr></thead><tr><td align="center" valign="middle" >coordtiff()</td><td align="center" valign="middle" >Extraction of X, Y coordinates from a Tiff image. Representation of the image using the first n harmonics. One image process.</td></tr><tr><td align="center" valign="middle" >image.to.coords()</td><td align="center" valign="middle" >Extraction of X, Y coordinates from a Tiff image. Faster algorithm for extracting coordinates from multiple images.</td></tr><tr><td align="center" valign="middle" >e.fourier.graph()</td><td align="center" valign="middle" >Represents a Tiff image using n harmonics.</td></tr><tr><td align="center" valign="middle" >automatic.PCAfourier.analysis1()</td><td align="center" valign="middle" >Perform an automatic multivariate (PCA) of the EFD coefficients and geometric image analysis (euclidean distance and medoids) from the extracted coordinates matrix or a coordinate file. One image process.</td></tr><tr><td align="center" valign="middle" >automatic.PCAfourier.analysis2()</td><td align="center" valign="middle" >Second version of the last function with the parameters adapted to be called from apply() and analyse multiple images at the same time (see the examples for further information).</td></tr></tbody></table></table-wrap><sec id="s1_1"><title>1.1. Elliptic Fourier Descriptors</title><p>The functions e.fourier.graph() and automatic.PCAfourier.analysis1()are supported by the Elliptic Fourier Descriptor (EFD) method. It is a mathematical way to describe closed contours of images using coordinates previously extracted by the function coordtiff() or image.to.coords. It was first proposed as an application of the Fourier transform method [<xref ref-type="bibr" rid="scirp.71512-ref9">9</xref>] . The EFD performs the Fourier expansion of the x and y coordinates of the outline and outputs 4 coefficients for each harmonic. The first harmonic describes the best fit ellipse for the closed contour. The higher harmonics add more complex contour features; thus, the higher the harmonic, the finer the detail it describes. This method increases the number of coefficients in accordance with the harmonic.</p><p>We implemented the EFD algorithm in the functions e.fourier.graph() and automatic.PCAfourier.analysis1() laid out in [<xref ref-type="bibr" rid="scirp.71512-ref10">10</xref>] , as the base of the e.fourier.graph() function available in VisioBioshapeR.</p><p>Let T be the perimeter of the outline, and this perimeter then becomes the period of the signal. One sets <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x3.png" xlink:type="simple"/></inline-formula> to be the pulse. Then the curvilinear abscissa t varies from 0 to T. The outline contains k, a finite number, points. One can therefore calculate discrete estimators for every coefficient of the n<sup>th</sup> harmonics:</p><disp-formula id="scirp.71512-formula240"><label>(1)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/71512x4.png"  xlink:type="simple"/></disp-formula><p>where:</p><disp-formula id="scirp.71512-formula241"><label>(2)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/71512x5.png"  xlink:type="simple"/></disp-formula><p>and:</p><disp-formula id="scirp.71512-formula242"><label>(3)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/71512x6.png"  xlink:type="simple"/></disp-formula><p>where n is the index of the n<sup>th</sup> harmonic.</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x7.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x8.png" xlink:type="simple"/></inline-formula> are calculated similarly.</p><p>The first harmonic defines the ellipse that best fits the outline. One can then use the parameter of the first harmonic to normalise the data so that they can be invariant to size, rotation, and the starting position of the outline trace. The function then calculates a new set of Fourier coefficients<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x9.png" xlink:type="simple"/></inline-formula>. The invariant properties of the new normalised coefficients allow us to use the new coefficients for further multivariate analysis and comparison.</p><p>One obtains the set of normalised coefficients following the equations:</p><disp-formula id="scirp.71512-formula243"><label>(4)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/71512x10.png"  xlink:type="simple"/></disp-formula><p>where “scale” is the magnitude of the semi-major axis of the ellipse defined by the first harmonic, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x11.png" xlink:type="simple"/></inline-formula>is the rotation angle of the orientation of the first ellipse, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x12.png" xlink:type="simple"/></inline-formula>are the original harmonic coefficients and the last term, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x13.png" xlink:type="simple"/></inline-formula>, is the rotation angle of the starting point to the end of the ellipse.</p><p>To compute these parameters one can use the formulae supplied in [<xref ref-type="bibr" rid="scirp.71512-ref11">11</xref>] :</p><disp-formula id="scirp.71512-formula244"><graphic  xlink:href="http://html.scirp.org/file/71512x14.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.71512-formula245"><graphic  xlink:href="http://html.scirp.org/file/71512x15.png"  xlink:type="simple"/></disp-formula><p>with:</p><disp-formula id="scirp.71512-formula246"><graphic  xlink:href="http://html.scirp.org/file/71512x16.png"  xlink:type="simple"/></disp-formula><p>and:</p><disp-formula id="scirp.71512-formula247"><graphic  xlink:href="http://html.scirp.org/file/71512x17.png"  xlink:type="simple"/></disp-formula><p>and:</p><disp-formula id="scirp.71512-formula248"><graphic  xlink:href="http://html.scirp.org/file/71512x18.png"  xlink:type="simple"/></disp-formula><p>Using this method, the function e.fourier.graph() extracts valuable information from the image. <xref ref-type="fig" rid="fig2">Figure 2</xref> presents an example of the use of the EFD to analyse an image of a dragonfly using the first nine harmonics and the function e.fourier.graph().</p></sec><sec id="s1_2"><title>1.2. Principal Component Analysis</title><p>The automatic.PCAfourier.analysis1() and automatic.PCAfourier.analysis2() functions are assigned the task of obtaining a vector containing relevant features which are extracted from each image resulting from the geometric analysis of its form. The problem of feature selection is undoubtedly the most critical part of the framework, as the sensitivity and robustness of the identification algorithm depend closely on responsiveness to the information that has been obtained automatically. In this case, the characteristics that are extracted from the shape of the image are the main components of all the Fourier harmonics of an image using previously the EFD, the geometric centre of the image and the Euclidean distance of the coordinates.</p><p>PCA is a mathematical tool for analysing data in a way that allows us to identify patterns in the data, and for expressing the data in such a way as to highlight their similarities and differences. Patterns can be hard to find in data of a high dimension, as is the</p><fig id="fig2"  position="float"><label><xref ref-type="fig" rid="fig2">Figure 2</xref></label><caption><title> Reconstruction contour with a number of harmonics</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x19.png"/></fig><p>case of the data contained and compiled within an image, where graphical representation is not available.</p><p>Conceptually, the goal of PCA is to reduce the number of variables of interest to a smaller set of components; in this case, the coefficients related to images. PCA analyses all the variance in the variables and reorganises it into a new set of components equal in number to the number of original variables. The new components are independent and they decrease with respect to the amount of variance in the originals they account for. The first component captures most of the variance; the 2nd, second most; and so on, until all the variance is accounted for. However, only some components will be retained for further study (dimension reduction). Since the first few capture most of the variance, further analysis typically focuses on them.</p><p>So, we apply PCA to the data contained in the matrix of EFD coefficients obtained in the elliptic Fourier analysis, either for the EFD coefficients obtained up to a certain number of harmonics or for all the harmonics obtained in the EFD analysis.</p><p>We use the function princomp() of R [<xref ref-type="bibr" rid="scirp.71512-ref12">12</xref>] , which uses the spectral decomposition approach, to perform the PCA analysis.</p><p>Thus for each image, each of the four Fourier coefficients (<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x20.png" xlink:type="simple"/></inline-formula>) for each of the multiple harmonics becomes only 8 coefficients which are contained in the information matrix of each image (coefficient 1 of the 1st component, coefficient 2 of the 1st component, up to the 4th coefficient of the 2nd component). The main components are the coefficients of the matrix eigenvectors obtained by spectral decomposition.</p><p>The difference between automatic.PCAfourier.analysis1 and automatic.PCAfourier. analysis2 is that the first serves for the analysis of a single image at a time, either from the matrix of coordinates or a coordinate file, on the other hand automatic.PCAfourier. analysis2 has its origins in a list containing matrices of coordinates from multiple images or a single image. automatic.PCAfourier.analysis2 is therefore useful when multiple images are processed.</p></sec><sec id="s1_3"><title>1.3. Image Geometry: Medoids and Euclidean Maximum Distance</title><p>The automatic.PCAfourier.analysis1() function can also analyse the image geometrically to obtain the centroid(medoid) and the Euclidean distances between the coordinates.</p><p>One of the interesting points of the image is the geometric centre; but there are different ways to calculate it. We selected the medoid as a good estimator of the image centroid. Medoids are representative objects of the coordinates X,Y whose average dissimilarity to all the coordinates is minimal. The medoid is not equivalent to a median or a geometric median. A median is only defined on a 1-dimensional coordinate, and it only minimises dissimilarity to other coordinates X,Y for a specific distance metric. A geometric median is defined in any dimension, but is not necessarily a point from within all the coordinates.</p><p>To calculate the medoid, we selected in R [<xref ref-type="bibr" rid="scirp.71512-ref12">12</xref>] the function pam() from the cluster library (Kaufman and Rousseeuw, 1990). pam Compared to the k-means approach in kmeans, the function pam has the following features: (a) it also accepts a dissimilarity matrix; (b) it is more robust because it minimises a sum of dissimilarities instead of a sum of squared Euclidean distances; and (c) it provides a novel graphic display.</p><p>Another important pieces of information obtained for automatic.PCAfourier. analysis1() is the distance between the coordinates X,Y of the image, which can contain information about relevant characteristic such as in the distance between tree rings or comparing some images with others. In order to calculate the distance, we used the Euclidean distance between all pairs of coordinates and extracted the maximum of them.</p><p>Many other metrics can be considered for data analysis purposes in the future.</p></sec></sec><sec id="s2"><title>2. Examples Section</title><p>In order to demonstrate the utility of the VisioBioshapeR package, here we present 3 examples of its use, one of which is real, including the automatic identification of 35 Tiff images of 3 genera of diatoms from an inventory of the River Ebro (Spain).</p><p>The first example consists of shape analysis of 35 diatoms using three genera: Navicula (n = 9), Cocconeis (n = 18) and Diatoma (n = 8), from the River Ebro inventory. Images can be retrieved from three folders (class 1, class 2 and class 3 respectively) in the examples directory (see “Documentation and availability” section). We then present two more simple examples with a dragonfly from a binarised digital camera image and tree rings that are designed and plotted using Paint (Microsoft Paint).</p><sec id="s2_1"><title>2.1. Sample Image Gallery</title><p>The VisioBioshapeR library, image samples and *.r script with some examples and analysis can be found at GitHub.</p><p>You will need to load VisioBioshapeR and retrieve in R the example data file with the commands library (VisioBioshapeR). To start the analysis, the path to the gallery of example images needs to be set to the folder “Templates” which contains three folders “class 1”, “class 2” and “class 3”, with the binarised diatom images. In the root folder, we can also find the dfly.tif (dragonfly) and tree.tif (ring tree) images.</p><p>The tree ring image was designed and plotted using Paint software.</p><p><xref ref-type="fig" rid="fig3">Figure 3</xref> represents the flow of processes performed by the VisioBioshapeR library, where you can see the image to be analysed and the result as a vector of image information. This process can be automated easily.</p></sec><sec id="s2_2"><title>2.2. Automatic Identification of Diatoms</title><p>The first example of use refers to the automatic identification of diatoms; a requirement since 1999 [<xref ref-type="bibr" rid="scirp.71512-ref13">13</xref>] . Both the Windows software SHERPA [<xref ref-type="bibr" rid="scirp.71512-ref14">14</xref>] and the application developed by [<xref ref-type="bibr" rid="scirp.71512-ref15">15</xref>] automatically recognise diatoms, although neither of these allow use from R or general use for biological imaging.</p><fig id="fig3"  position="float"><label><xref ref-type="fig" rid="fig3">Figure 3</xref></label><caption><title> Scheme using the library to read and analyze images automatically</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x21.png"/></fig><p>The samples of diatoms presented in the example of the use of VisioBioshapeR (see <xref ref-type="fig" rid="fig4">Figure 4</xref>) were obtained through the standard diatom sampling method and collected from a previous study on characterisation of the ecological state of the Ebro basin [<xref ref-type="bibr" rid="scirp.71512-ref16">16</xref>] .</p><p>We selected the three genera Navicula, Cocconeis and Diatoma because of their relative abundance in the samples and thus the higher probability of finding the target diatom valves in the samples. Moreover, these species are common in European rivers.</p><p>The taxonomic rank in this study was downgraded to genus so we can obtain more image samples from the ADIAC database [<xref ref-type="bibr" rid="scirp.71512-ref13">13</xref>] .</p><p>The observation and identification was performed using a Carl Zeiss Jenaval bright field microscope with phase contrast lenses Planachromat Phv 100&#215;/1.3 and normal lenses 100&#215;/1.3. The images were taken with an Olympus DP25 FW digital camera and the associated software Olympus Cell<sup>^</sup> B. The images have 2560 &#215; 1920 pixels, where each pixel equals 0.03376 mm<sup>2</sup>.</p><p>In each photograph session we obtained background images to correct irregularities in the light source of the microscope. The background was corrected by subtracting the background image from the normal image and thus obtaining a standardised image with regular background and colour correction.</p><p>We used the SHERPA software [<xref ref-type="bibr" rid="scirp.71512-ref14">14</xref>] for the segmentation of the standardised images. Then we obtained the final binary images by binarising the results of the SHERPA analysis in Tiff format.</p><p>In the following sections we demonstrate how to use the different functions in the three examples (diatoms, dragonfly and tree rings).</p></sec><sec id="s2_3"><title>2.3. Coordinate Extraction from the Images</title><p>To obtain the outline of each image of interest we propose two solutions, one for the analysis of individual images, very versatile and allows the analysis of sub-images within a single image, it is the function Coordtiff() and another is the function image.to.coords(), more efficient computationally and that is destined to rapid removal of the images of a directory, all at once. The last must not have more than a single Tiff image to extract the coordinates correctly. Coordtiff() can interactively display the image once extracted coordinates and image.to.coords() does not.</p><p>For the Coordtiff() function we used a modification of the Conte function [<xref ref-type="bibr" rid="scirp.71512-ref10">10</xref>] : a classical R function used in the outline detection of a new image. This modification allows us to generate randomly all the automatic outlines for an image. The outlines are detected by first transforming the images into grey-scale images using the option “pixmapGrey”. The images are then binarised using a threshold pixel value (intensity threshold) which can be defined by the user. The outlines are then collected automatically in a list of X,Y coordinates to uniquely determine the position of a point of the image on a manifold of the graph space. The order of the coordinates is significant and is known as “the x-coordinate” and “the y-coordinate”.</p><p>The modified Conte function was named Coordtiff() and is defined as:</p><p>&gt;Coordtiff(file, harmonic = F)</p><p>The file argument is used to read the images in Tiff format using the function readTiff [<xref ref-type="bibr" rid="scirp.71512-ref17">17</xref>] . The harmonic argument is used to perform a previous EFD analysis by means of the function efourier [<xref ref-type="bibr" rid="scirp.71512-ref10">10</xref>] and represent the reconstruction of the original image graphically using a number of the first 9 harmonics. The function returns a data frame which contains the X, Y coordinates of the outline of each image. The main advantage of the function Coordtiff() with respect to Conte is that if the image has different sub-images (for example tree rings), it can separate them all out.</p><p>An example of use of the function Coordtiff() is presented in <xref ref-type="fig" rid="fig3">Figure 3</xref> using a binarised image of a dragonfly, where we can see a red line that represents the coordinates extracted overlaid on the image.</p><p>image.to.coords() is defined as:</p><p>&gt;image.to.coords(filename, foldername, folder = F)</p><p>The filename argument is used to read a single image in Tiff format. The folder argument is a Boolean value that tells the function if we are reading a set of images in a folder (T) or a single image (F). foldername argument is the relative path to the folder. The algorithm for the outline extraction is from the raster library [<xref ref-type="bibr" rid="scirp.71512-ref17">17</xref>] originally used for extract the coordinates of a contour map. So the benefits of the function are a faster execution time and a more scalable data set reading tool.</p></sec><sec id="s2_4"><title>2.4. EFD Analysis and Reconstruction of the Image</title><p>When all the outlines have been captured and stored in the form of X,Y coordinates, the shape coefficients of the image can be extracted using the function e.fourier.graph(). The EFD technique is performed using the efourier function [<xref ref-type="bibr" rid="scirp.71512-ref10">10</xref>] and the original im-</p><fig id="fig4"  position="float"><label><xref ref-type="fig" rid="fig4">Figure 4</xref></label><caption><title> Example of diatoms used for automatic identification from the River Ebro (Spain) inventory</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x22.png"/></fig><p>age is represented with the reconstructed image using its harmonics (by default: 9 harmonics) by means of the iefourier function. The function e.fourier.graph is a modification of efourier which adds the possibility of normalising the images with regard to size and rotation using the function NEFnormalization and groups the coefficients with regards to size and rotation, then displays the coefficients.</p><p>The function is defined as:</p><p>&gt;e.fourier.graph(M,n.harmonics = 9, coef = F, normalized = T)</p><p>The M argument is used to read the coordinates X and Y from the images using the function Coordtiff The n.harmonic argument is used to perform EFD analysis by means of the function efourier and to represent the reconstruction of the original image graphically using the function iefourier using a first n.harmonic harmonics.</p><p>The function returns the four coefficients <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x23.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x23.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x24.png" xlink:type="simple"/></inline-formula> for each image if the argument coef = T.</p><p>The normalised argument is used to normalise (or not) the images with regards to size and rotation, and group the coefficients with regards to size and rotation, then to display the coefficients</p><p><xref ref-type="fig" rid="fig2">Figure 2</xref> and <xref ref-type="fig" rid="fig3">Figure 3</xref> show examples of the use of e.fourier.graph() using an image of a dragonfly, reading the X,Y coordinates (<xref ref-type="fig" rid="fig3">Figure 3</xref>) and performing EFD analysis and reconstruction the image with the first 9 harmonics.</p><p>One of the purposes of this functions is adjust the number of harmonics required to a suitable reconstruction of the images in the extraction of the vector containing image information using the function automatic.PCAfourier.analysis1().</p></sec><sec id="s2_5"><title>2.5. Shape Coefficients</title><p>When all the outlines have been captured in a image, the number of harmonics required is adjusted and normalisation is performed if necessary, the shape coefficients can be extracted and used for PCA analysis using the function automatic.PCAfouri- er.analysis1().</p><p>15 harmonics by default are used to give 4 elliptic Fourier coefficients (if the normalised option is used, the first three coefficients are omitted due to standardisation in relation to size, rotation and starting point).</p><p>The function is defined as:</p><p>&gt;automatic.PCAfourier.analysis1(file, M, id.num, nom.label, tipus.input = 2, normalised = FALSE, num.harmonic = 15)</p><p>The file and M arguments are used to read the coordinates X, Y from the images using the function Coordtiff() in the case of using M or directly if we read a file containing the X,Y coordinates of the image.</p><p>The id.num argument is used to assign a number to the image analysed. The nom.label argument is used to assign a label (character) to the new image analysed. The argument tipus.input = 2 indicates to the function that we are reading a matrix, M, with the coordinates X and Y, and if we use tipus.input = 1 we are reading a file with the coordinates.</p><p>The normalised argument is used to normalise (or not) the images with regards to size and rotation and groups the coefficients with regards to size and rotation, and then displays the coefficients.</p><p>After the EFD analysis, in a second step, the function automatic.PCAfourier. analysis1() performs PCA analysis of the four first coefficients <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x25.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x25.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/71512x26.png" xlink:type="simple"/></inline-formula> of all the harmonics obtained during the EFD analysis and another PCA analysis of an initial num.harmonic (by default: first 15 harmonics). In another step, the function calculates the centroid of the image using medoids of the cluster library. Finally, automatic.PCAfourier.analysis1() calculates the Euclidean distance between all the coordinates previously extracted and obtains the maximum Euclidean distance.</p><p>The function returns 21 variables containing information about the geometry of the image using the EFD, PCA and Euclidean analysis of the image:</p><p>・ Column 1: numerical ID of the image</p><p>・ Column 2: image label</p><p>・ Columns 3 - 10: PCA coefficients of all the EFD coefficients</p><p>・ columns 11 - 18: PCA coefficients of selected (nharmonics) elliptic Fourier coefficients</p><p>・ Columns 20 - 21: X and Y centroids of the image using the medoids</p><p>・ Column 21: Euclidean maximum distance between the X,Y coordinates.</p></sec><sec id="s2_6"><title>2.6. Automatic Classification Analysis</title><p>Finally, in the example of R script we present a complete example of classification of biological images using 35 Tif images of 3 frequent genera of diatoms (navicula (n = 9), cocconeis (n = 18) and diatoma (n = 8)) from the River Ebro (Spain) that are shown in <xref ref-type="fig" rid="fig4">Figure 4</xref>. The objective was to obtain an automatic classification of the biological images for use with new images, using VisioBioshapeR.</p><p>The first step (see <xref ref-type="fig" rid="fig3">Figure 3</xref>) was to read the coordinates of all the Tiff images automatically (<xref ref-type="fig" rid="fig4">Figure 4</xref>) using the function Coordtiff() and store them in a vector of coordinates X,Y. The second step was to create a matrix to collect all the PCA-EFD coefficients obtained during the previous analysis using the automatic.PCAfourier.analysis1() function and group them in a matrix with 35 rows and more than 21 columns, indicating an ID and a label for each image. At the end, we created a new row with the class of diatoms (1 for navicula, 2 for cocconeis, 3 for diatoma). In the R script we present the use of some classification multivariate methods to obtain a discriminant function that allows us to separate different genera (<xref ref-type="table" rid="table2">Table 2</xref>).</p><p>In <xref ref-type="table" rid="table2">Table 2</xref> we can see the percentage (%) of good classification using different methods:</p><p>We used the following discriminant methods to separate the three genera of diatoms using the variables calculated in the EFD-PCA:</p><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> In brackets: the number of variables used</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Method</th><th align="center" valign="middle" >navicula</th><th align="center" valign="middle" >cocconeis</th><th align="center" valign="middle" >diatoma</th><th align="center" valign="middle" >all</th></tr></thead><tr><td align="center" valign="middle" >LDA(12)</td><td align="center" valign="middle" >66.7</td><td align="center" valign="middle" >88.9</td><td align="center" valign="middle" >85.7</td><td align="center" valign="middle" >82.9</td></tr><tr><td align="center" valign="middle" >LDA(12CV)</td><td align="center" valign="middle" >33.3</td><td align="center" valign="middle" >66.7</td><td align="center" valign="middle" >25</td><td align="center" valign="middle" >48.6</td></tr><tr><td align="center" valign="middle" >LDA(6CV)</td><td align="center" valign="middle" >66.7</td><td align="center" valign="middle" >77.7</td><td align="center" valign="middle" >50</td><td align="center" valign="middle" >68.6</td></tr><tr><td align="center" valign="middle" >RRLDA(13)</td><td align="center" valign="middle" >55.6</td><td align="center" valign="middle" >55.6</td><td align="center" valign="middle" >87.5</td><td align="center" valign="middle" >62.8</td></tr><tr><td align="center" valign="middle" >FDA(13)</td><td align="center" valign="middle" >88.9</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >97.1</td></tr><tr><td align="center" valign="middle" >NN(13)</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >100</td></tr><tr><td align="center" valign="middle" >NN(3)</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >88.9</td><td align="center" valign="middle" >75</td><td align="center" valign="middle" >88.6</td></tr><tr><td align="center" valign="middle" >SVM(13)</td><td align="center" valign="middle" >55.5</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >87.5</td><td align="center" valign="middle" >85.7</td></tr></tbody></table></table-wrap><p>・ LDA: Fisher linear discriminant analysis (with CV: Cross validation) using the MASS library,</p><p>・ RRLDA: Robust Regularised Linear Discriminant Analysis using the rrlda library,</p><p>・ FDA: Flexible Discriminant Analysis using the mda library,</p><p>・ NN: Neural Nets using the nnet library,</p><p>・ SVM: support vector machine using the kernlab library.</p><p>The percentage of good classification varies between 50% and 100%, and specially some methods can be considered useful to classify organism using the procedures by means of the library.</p></sec><sec id="s2_7"><title>2.7. Other Examples</title><p>Another two examples are offered in the R script. First was a dragonfly (<xref ref-type="fig" rid="fig2">Figure 2</xref>, <xref ref-type="fig" rid="fig5">Figure 5</xref>) and the second, more complex was to analyse automatically an image of tree rings designed in order to apply it to tree growth analysis (see <xref ref-type="fig" rid="fig6">Figure 6</xref> and <xref ref-type="fig" rid="fig7">Figure 7</xref>). Thus, we can obtain the distance between rings represented in <xref ref-type="fig" rid="fig7">Figure 7</xref>, where the X coordinates are the tree rings and Y is the distance between rings. So this could be useful to study tree growth or for climate reconstruction.</p></sec></sec><sec id="s3"><title>3. Conclusions and Prospects</title><p>The VisioBioshapeR library has demonstrated its usefulness in the three examples presented in this work. All the examples used in this paper were collected in R script to illustrate the utilities.</p><p>As we have seen in the above examples (dragonfly, tree rings and diatoms) this VisioBioshapeR library is acceptable for the specific purpose and has a wide variety of uses in automatic identification of biological images.</p></sec><sec id="s4"><title>Acknowledgements</title><p>We thank the research group in diatoms led by Professor Jaume Cambra, Nuria Flor and Andrea Burfeid of the Botanical Department at the UB for their help and support, analysis of samples and providing images of diatoms.</p><fig id="fig5"  position="float"><label><xref ref-type="fig" rid="fig5">Figure 5</xref></label><caption><title> Extraction of the X,Y coordinates from the image of a dragonfly</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x27.png"/></fig><fig id="fig6"  position="float"><label><xref ref-type="fig" rid="fig6">Figure 6</xref></label><caption><title> Extraction of the coordinates X,Y in a tree rings analysis using the Coordtiff() function</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x28.png"/></fig><fig id="fig7"  position="float"><label><xref ref-type="fig" rid="fig7">Figure 7</xref></label><caption><title> Analysis of the growth of a tree from automatic image analysis of its rings</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/71512x29.png"/></fig><p>We also thank the Faculty of Biology at the UB for a grant it awarded in 2015 to support this project.</p></sec><sec id="s5"><title>Documentation and Resources</title><p>The website for VisioBioshapeR can be found at GITHUB: https://github.com/BielStela/VisioBioShapeR.</p><p>It contains the library, an “R” script with the examples and a “zip”’ folder with all the images commented on and used in the examples.</p></sec><sec id="s6"><title>Cite this paper</title><p>Stela, B. and Monle&#243;n-Getino, A. (2016) Facilitating the Automatic Characterisation, Classification and Description of Biological Images with the VisionBioShape Package for R. Open Access Library Journal, 3: e3108. http://dx.doi.org/10.4236/oalib.1103108</p></sec></body><back><ref-list><title>References</title><ref id="scirp.71512-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Libungan, L.A. and Pálsson, S. (2015) Shaper: An r Package to Study Otolith Shape Variation among Fish Populations. PloS ONE, 10, e0121102. http://dx.doi.org/10.1371/journal.pone.0121102</mixed-citation></ref><ref id="scirp.71512-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Yang, H.-P., Ma, C.-S., Wen, H., Zhan, Q.-B. and Wang, X.-L. (2015) A Tool for Developing an Automatic Insect Identification System Based on Wing Outlines. Scientific Reports, 5, 12786. http://dx.doi.org/10.1038/srep12786</mixed-citation></ref><ref id="scirp.71512-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Uchida, S. (2013) Image Processing and Recognition for Biological Images. Development, Growth &amp; Differentiation, 55, 523-549. http://dx.doi.org/10.1111/dgd.12054</mixed-citation></ref><ref id="scirp.71512-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Ginoris, Y.P., Amaral, A.L., Nicolau, A., Coelho, M.A.Z. and Ferreira, E.C. (2007) Recognition of Protozoa and Metazoa Using Image Analysis Tools, Discriminant Analysis, Neural Networks and Decision Trees. Analytica Chimica Acta, 595, 160-169. http://dx.doi.org/10.1016/j.aca.2006.12.055</mixed-citation></ref><ref id="scirp.71512-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Ghazali, K.H., Alsameraai, R.S.H. and Mohamed, Z. (2013) Automated System for Diagnosis Intestinal Parasites by Computerized Image Analysis. Modern Applied Science, 7, 98- 114. http://dx.doi.org/10.5539/mas.v7n5p98</mixed-citation></ref><ref id="scirp.71512-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Shamir, L., Delaney, J.D., Orlov, N., Mark Eckley, D. and Goldberg, I.G. (2010) Pattern Recognition Software and Techniques for Biological Image Analysis. PLoS Computational Biology, 6, e1000974. http://dx.doi.org/10.1371/journal.pcbi.1000974</mixed-citation></ref><ref id="scirp.71512-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Tan, C.S., Lau, P.Y., Phang, S.-M. and Low, T.J. (2014) A Framework for the Automatic Identification of Algae (Neomeris vanbosseae M.A. Howe): U3S. 2014 International Conference on Computer and Information Sciences (ICCOINS), Kuala Lumpur, 3-5 June 2014, 1-6.</mixed-citation></ref><ref id="scirp.71512-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Avci, D. and Varol, A. (2009) An Expert Diagnosis System for Classification of Human Parasite Eggs Based on Multi-Class SVM. Expert Systems with Applications, 36, 43-48. http://dx.doi.org/10.1016/j.eswa.2007.09.012</mixed-citation></ref><ref id="scirp.71512-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Kuhl, F. and Giardina, C. (1982) Elliptical Fourier Features of a Closed Contour. Computer Graphics Image Processing, 18, 236-258. http://dx.doi.org/10.1016/0146-664X(82)90034-X</mixed-citation></ref><ref id="scirp.71512-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Claude, J. (2008) Morphometrics with R. Springer, Berlin.</mixed-citation></ref><ref id="scirp.71512-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Rohlf, F.J., Ferson, S. and Koehn, R.K. (1985) Measuring Shape Variation of Two-Dimensional Outlines. Systematic Zoology, 34, 59-68. http://dx.doi.org/10.2307/2413345</mixed-citation></ref><ref id="scirp.71512-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">R Core Team (2015) R: A Language and Environment for Statistical Computing.</mixed-citation></ref><ref id="scirp.71512-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Buf, H.D., Bayer, M., Droop, S., Botanic, R., Edinburgh, G., Head, R., Juggins, S., Fischer, S. and Bunke, H. (1999) Diatom Identification: A Double Challenge Called ADIAC. International Conference on Image Analysis and Processing, Italy, 27-29 September 1999. http://dx.doi.org/10.1109/ICIAP.1999.797682</mixed-citation></ref><ref id="scirp.71512-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Kloster, M., Kauer, G. and Beszteri, B. (2014) SHERPA: An Image Segmentation and Outline Feature Extraction Tool for Diatoms and Other Objects. BMC Bioinformatics, 15, 218. http://dx.doi.org/10.1186/1471-2105-15-218</mixed-citation></ref><ref id="scirp.71512-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Jalba, A.C., Wilkinson, M.H.F., Roerdink, J.B.T.M., Bayer, M.M. and Juggins, S. (2005) Automatic Diatom Identification Using Contour Analysis by Morphological Curvature Scale Spaces. Machine Vision and Applications, 16, 217-228. http://dx.doi.org/10.1007/s00138-005-0175-8</mixed-citation></ref><ref id="scirp.71512-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Flor-Arnau, N., Cambra, J. and Burfeid Castellanos, A.M. (2012) Referencia y red básica de diatomeas en la cuenca del ebro. evaluación del estado ecológico de las masas de agua superficiales de la cuenca del ebro utilizando las diatomeas bentónicas como bioindicadores resultados anos 2011-2012. Confederación Hidrográfica del Ebro.</mixed-citation></ref><ref id="scirp.71512-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Hijmans, R.J. (2015) Raster: Geographic Data Analysis and Modeling. R Package Version 2.5-2.</mixed-citation></ref></ref-list></back></article>