GEOLOGIJA 58/2, 247-260, Ljubljana 2015 http://dx.doi.org/10.5474/geologija.2015.020 © Author(s) 2015. CC Atribution 4.0 License Computer aided method for colour calibration and analysis of digital rock photographs Računalniško podprta metoda za barvno umerjanje in analizo digitalnih fotografij kamnin Matic POTOČNIK1, Bojan KLEMENC1, Franc SOLINA1 & Uroš HERLEC2 1FRI, UL, Večna pot 113, SI-1000 Ljubljana, maticpotocnik@gmail.com, bojan.klemenc@fri.uni-lj.si 2NTF, UL, Aškerčeva cesta 12, Ljubljana, uros.herlec@gmail.com Prejeto / Received 11. 10. 2014; Sprejeto / Accepted 4. 12. 2015; Objavljeno na spletu / Published online 30. 12. 2015 Key words: digital photography, colour calibration, colour analysis, digital rock photograph colour analysis, Munsell colour system Ključne besede: digitalna fotografija, barvno umerjanje, barvna analiza, barvna analiza digitalnih fotografij kamnin, barvni sistem Munsell Abstract The methods used in geology to determine colour and colour coverage are expensive, time consuming, and/ or subjective. Estimates of colour coverage can only be approximate since they are based on rough comparison-based measuring etalons and subjective estimation, which is dependent upon the skill and experience of the person performing the estimation. We present a method which accelerates, simplifies, and objectifies these tasks using a computer application. It automatically calibrates the colours of a digital photo, and enables the user to read colour values and coverage, even after returning from field work. Colour identification is based on the Munsell colour system. For the purposes of colour calibration we use the X-Rite ColorChecker Passport colour chart placed onto the photographed scene. Our computer application detects the ColorChecker colour chart, and finds a colour space transformation to calibrate the colour in the photo. The user can then use the application to read colours within selected points or regions of the photo. The results of the computerised colour calibration were compared to the reference values of the ColorChecker chart. The values slightly deviate from the exact values, but the deviation is around the limit of human capability for visual comparison. We have devised an experiment, which compares the precision of the computerised colour analysis and manual colour analysis performed on a variety of rock samples with the help of geology students using Munsell Rock-color Chart. The analysis showed that the precision of manual comparative identification on multicoloured samples is somewhat problematic, since the choice of representative colours and observation points for a certain part of a sample are subjective. The computer based method has the edge in verifiability and repeatability of the analysis since the application the original photo to be saved with colour calibration, and tagging of colour-analysed points and regions. Izvleček Metode, ki se v geologiji uporabljajo za določanje barv in barvne pokritosti, so drage, zamudne in/ali subjektivne. Ocena barvne zastopanosti ali pokritosti je lahko le zelo približna, saj temelji na grobih primerjalnih etalonih in subjektivni oceni, ki je odvisna od izurjenosti in izkušenj ocenjevalca. Predstavljamo metodo, ki te naloge pospeši, poenostavi in objektivizira s pomočjo računalniške aplikacije, ki na zajeti digitalni fotografiji z uporabo računalniškega vida samodejno umeri barve in uporabniku tudi kasneje, po terenskem delu, omogoča odčitavanje barvnih odtenkov. Barvna identifikacija temelji na barvnem sistemu Munsell. Za barvno umerjanje uporabljamo umerjevalno barvno lestvico X-Rite ColorChecker Passport, ki jo uporabnik postavi v območje zajema fotografije kamnine. Računalniška aplikacija, ki smo jo razvili, na zajeti fotografiji zazna barvno lestvico ColorChecker in poišče transformacijo barvnega prostora, s katero fotografijo barvno umerimo. Uporabnik lahko nato s pomočjo aplikacije po barvnem sistemu Munsell odčita barvo v izbranih točkah in izbranih področjih na fotografiji. Rezultate računalniško podprtega barvnega umerjanja smo primerjali z referenčnimi vrednostmi barvne lestvice ColorChecker. Rezultati umerjanja kažejo, da računalniška metoda umeri dovolj natančno točne barvne vrednosti, tako da je barvno odstopanje blizu meje, ki jo človek še lahko razloči. Za primerjavo smo opravili poskus, pri katerem smo na raznovrstnih primerkih kamnin primerjali natančnost računalniške barvne analize z ročnimi barvnimi primerjalnimi analizami študentov geologije s pomočjo lestvice Munsell Rock-color Chart. Ugotovili smo, da nastopajo velike razlike v odčitkih predvsem pri raznobarvnih kamninah zaradi subjektivnosti izbora najbolj reprezentativnih barv za posamezni analizirani kos kamnine oziroma lege reprezentativnih primerjalnih točk. Prednost računalniške metode je tako v preverljivosti in ponovljivosti analize, saj aplikacija omogoča shranjevanje originalne in barvno umerjene fotografije ter označitve lege posamične analizirane točke in območja opravljanja barvne analize. 248 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC Introduction The methods used in geology to determine colours are: (a) verbal description, which is dependent upon the skill and visual perception of the person performing it, and is thus subjective, (b) measurement using a spectrophotometer, which is time consuming, expensive and impractical for field work, and (c) comparison based comparative determination using a colour chart (e.g. Munsell Rock Colour chart), which can be time consuming, especially for rocks with many colour shades, and is not always appropriate for field work since the colour patches are sensitive to weather and environmental conditions. Estimates of colour coverage can only be approximate, since they are based on rough comparison-based measuring etalons and is also dependent upon the skill and experience of the person performing the assessment. Statistical assessment of colour "classes" is possible if points on a regular grid are used to count occurrences of each"class','but this method is also time consuming and thus expensive, and not commonly used. With more objective colour values and statistically significant rock colour coverage analyses we could extract much more significant and consequently valuable rock data parameters. We introduce a method, which greatly accelerates and simplifies these tasks, and makes them more objective. We have developed a computer application for automatic colour calibration of digital photographs made either during field work, or in the laboratory, which allows the user to accurately identify colours in the Munsell colour system; a standard used in geology for colour determination. We use the X-Rite ColorChecker Passport reference colour chart in combination with computer vision and colour calibration algorithms. This enables completely automated colour calibration of digital photographs. Colour calibration is a necessary step, since it greatly improves the quality of the colour information by diminishing the various effects, such as weather, illumination, the photographic equipment used, etc. Before capturing a digital photograph, the ColorChecker chart needs to be placed into the photograph capture area of the rock we wish to analyze. To ensure a good baseline and thus improve the accuracy of results, the illumination should be as uniform as possible. Additional lighting or camera flash can be used to achieve this, if natural illumination conditions are not favourable or if the angle of sunlight produces shadows. Existing methods for colour calibration used in professional photography are either manual or semi-automatic and are more focused on providing the photographer with tools to achieve the best aesthetic effect, not necessarily the most correct colour information (Van Hurkman, 2013). The photographers also use the calibration tools differently, since they capture one image with the colour chart, and then (keeping other parameters as similar as possible) capture the images they have actually set out to photograph. The existing tools are shaped by this mode of work, and are not well suited for the use case covered by the application we have developed, i.e. completely automatic colour calibration and a user interface focused on objective analysis rather than aesthetics. The computer application we developed uses the ASIFT algorithm (Yu & Morel, 2011) to detect the ColorChecker chart on the captured photograph, and then determines a transformation of the CIE Lab colour space, which then colour-calibrates the photograph. The user is then able to read out the colour values in selected points and regions. Approximate measuring of distances on the photograph is also possible, if we assume the objects are in the same plane as the ColorChecker chart. Differences in colour of rocks and soils is the result of differences in qualitative and quantitative mineral composition and, in particular, in the presence and quantity of the pigment minerals (most common are lepidocrocite, goethite and hematite). Mineral and chemical composition determination requires complex and time consuming sampling and more costly analyses. Unfortunately the number of such analyses is limited by available funds. Due to the fact that colour is one of the basic properties/attributes of rock, which is noticed macroscopically in the field, an objective capture is very important and useful. Rocks within some lithologic units are unicoloured, which means, that the variability of colour values is within a very narrow range of colour hue. In such cases field researchers do not compare their colour with the colour chart on every outcrop, but rather assign the same colour value on the basis of previous observation experiences. This shortens observation and time needed for comparison, but they can unwittingly neglect differences in the lateral colour variability within the same lithostratigraphic unit and lose part of the information. Huge variability of colour within the same lithostratigraphic unit of clastic sedimentary rocks reflects differences in their microenvironment of their origin (sedimentation energy) resulting into grain-size differences and also differences in the mineral composition, porosity and permeability of the sedimentary clastic rocks and consequently onto differences in the oxygen availability during diagenetic processes. This influences the oxidation state of the pigment minerals. Multicoloured lithostratigraphic units contain several indirect colour information on grain size, mineral composition and genetic environment and rock diagenetic processes. A number of determined colours is fully left to the subjective decision of the observer, who will usually, due to the time needed for a full procedure, only determine a few characteristic colours based on their needs or a regional similarity approach. A more objective capture of the colour range and colour coverage would undoubtedly offer a lot of additional information. Computer aided method for colour calibration and analysis of digital rock photographs 249 The processes of magmatic and metamorphic rocks genesis also result in their different mineral and grain size composition and consequently a different colour range and coverage. As much as possible objective and detailed colour analysis can offer very useful additional information which enable simple and significant statistical comparison between rock samples and rock outcrops within the same lithostratigraphic units and between the different ones. The proposed computer aided method of colour calibration and analysis is based on the Munsell, CIE XYZ and CIE Lab colour models and calculates colour distances within them and a short overview of these models follows.- CIE 1931 XYZ Colour Model CIE XYZ, which was standardized in 1931, was the first mathematically defined colour model that still serves as the basis for newer models and as the linking model used to convert colour values from one model to another. The model is comprised of three components: X, Y, and Z which were modelled after the human visual system with its three types of cone cells. Experimental data determined how strongly each type of cone cell responds to some wavelength of light, and from the response the colour matching functions x(X), y (X) and z (X) (Schanda, 2007) were derived. A spectrophotometer is a device for measuring material reflectance values at different wavelengths. If we integrate the reflectance measurements with the colour matching functions we get the colour values for the components X, Y, and Z respectively. The values also vary depending on the illuminant used to perform the measurements which is also defined as a function of 1. The International Commission on Illumination (CIE) has also provided several standard illumination sources. Unless otherwise specified the values in this article use the D65 standard illuminant which is modelled after natural daylight on Earth. Spectrophotometers are used in laboratories, but are impractical for field work and are very expensive devices. Further drawbacks of their use is a small operating range, usually a few millimeters, the inability to directly measure colour coverage, sampling is required, and the inability to measure rough uneven surfaces (Ruiz & Pereira, 2014). Munsell colour system The Munsell colour system (Munsell, 1905) was developed by prof. Albert H. Munsell with the goal of creating a perceptually uniform system. Perceptual uniformity means that an equal change of a colour component anywhere inside the system means approximately the same perceptual difference to a human observer. Colour in the Munsell system is determined by three components: hue, value, and chroma. 250 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC The first component, "Hue',' is given as number from 0 to 10, and a one or two letter abbreviation of the hue name. Apart from the colour hues in Fig. 1, there is also a special abbreviation N, which stands for neutral and is reserved for grey shades. "Value" determines the lightness of a colour on a scale from 0 (black) to 10 (white). The third component, "chroma" determines the saturation and has no upper bound in theory, but in practice it is limited by the pigments that can be manufactured. A neutral colour has a chroma value of 0, the highest value we find in the Rock and Soil charts is 8 and 20 would mean a very saturated colour. The advantages of the Munsell system are intuitive components, and a long tradition of use in industry, art, and science. The drawback is that it is not a mathematically defined colour model, and is connected to the mathematically defined models only by tables of measurements (RIT Munsell color science Laboratory), which makes exact calculation and conversion difficult. Use of Munsell colour system in Geology The Munsell system has a long tradition of use in geology. In 1948 the Geological Society of America (GSA) released the first Rock-color Chart based on the Munsell system. In 1949 the Munsell Color Company collaborated with the United States Department of Agriculture (USDA) to release the first "Munsell Soil-color Chart" These are books of colour charts intended for comparative determination of colour values of rocks and soil. Both books are still available in updated editions and still in widespread use. They have effectively become the standard for colour communication in geology. Munsell colour charts are used both for geological field work and work in a laboratory. The comparative method is a lot more precise and objective than verbal descriptions of colours, but is still somewhat subjective and inaccurate, because the books contain a limited number of colour patches, and because of the limitations of the human visual system to accurately distinguish colour differences. Munsell Soil-color Chart (X-Rite, Inc., 2009c) contains nine pages, which cover colours with hues from 5R to 5Y at various values of value and chroma components, and four additional pages; one with a few colours with hue values 10Y and 5GY, two pages with low-chroma colours for gleysols, and one page with colours with a high value component. The colours on pages are sorted in two dimensions by value and chroma, so the user can gain a feel for the colours with a particular hue, and can in some cases decide to visually interpolate and assign a colour not depicted in the chart. Rock-color Chart (X-Rite, Inc., 2009b) contains only three pages with the most common rock colours. The colours are not sorted by any of the Munsell system components, which prevents visual interpolation. Each page of colour chart contains up to 42 colour patches, usually fewer, since some pigments are more expensive or difficult to produce. Each colour patch has a hole to allow direct comparison of the patch with the rock or soil for which the colour is being determined. Next to each colour page is a page with the Munsell values and colour names in the ISCC-NBS system, according to the mapping defined in (Kelly & Judd, 1976). The design purpose of ISCC-NBS was to improve the accuracy of colour descriptions by constraining the language to a set of colour names and a few standard adjectives (e.g. dark, vivid, very pale), and to define which parts of the Munsell system correspond to which colour descriptions. Fig. 2. Munsell Soil-color and Munsell Rock-color charts. 1 ****** ***** k S KB*** ***** **** ** Computer aided method for colour calibration and analysis of digital rock photographs 251 CIE Lab colour model The International Commission on Illumination (CIE) accepted the CIE Lab colour model in 1976. A colour in CIE Lab is defined by three components: L* - lightness, a* - red/green, and b* - blue/yellow. CIE Lab was designed to be perceptually uniform on all three components at once, and is mathematically defined, which makes it very appropriate for colour computation. Measuring colour distance When working with colour, e.g. in print, or industrial design, a common task is tolerancing -checking if colours are acceptably close to some predefined standard. A colour distance measure, where, to the human eye, the same distance means the same amount of change, is very useful, since it can be used for all the colours used. In this section we will mention three formulas for colour distance (schanda, 20)07), which have been implemented in our computer applicntion. Sinne CIE Lab was designed with good perceptual uniformity on all componHnts at once, the first colour distance measure CIE is simply ihe Euclidean di stanc e of the per component dsltas of two colour's: ae. 76 = vaí/ 2 + ¿la*2 + /1¿>* Later it whs found that CIE Lob is not completely perceptually uniform, so in 199)44 CIE Lab confirmeda new formula CIE , which wos based on a iarge amoui of experimental data collected by the automotive industry. This formula i s defin ed on CIE LCH - a colour model rei ated to CIE Ltb, with the same L* eomponent and C* - chroma, and H* - hue, which are simply polar definitions ofa* and b*. ae!" = al* ac, ah, (-)2 + (——)2 + (——) ^l kc sc ^hsh In the year 2000 CIE released another formula, CIE , -which experimentally works very well for small colour distances, but has some mathematical discontinuities which skew the results at larger distances (Sharma et al., 2005). AE* = All AC AH' AC AH' (/T2T)2 + (Fs-)2 + (rar)2+it re Another difficulty we had when working with CIE is that .he formula takes a lot more computing time. Because of these issuea we use CIE for most tasks, and CIE where the expected difference is small. For an easier interpretation of later results, let us provide some context to the values from these formulas. The limit at which the average human observer barely distinguishes two colours if laid next to each other is 2.3. This value is called the just noticeable difference (JND) (Mahy et al., 1994). The approximate distance between neighbouring grey shades on the ColorChecker chart is 15. The average of distances between pairs of nearest colour values on the Munsell Rock-color chart is 5.4 (highly saturated colours a bit farther apart, and colours with low saturation a bit nearer). Development of the application ColorChecker colour calibration chart ColorChecker colour chart was developed in 1976 by the Macbeth company (today part of X-Rite company) (McCamy et al., 1976). The chart is used for the colour calibration of different devices (e.g. cameras, printers, displays). ColorChecker colour chart contains four lines with six colour patches, 24 patches in all. Patches have precisely defined colour values which can be used to check the quality of colour reproduction or colour acquisition. The first two lines contain approximations of some common natural hues (e.g. human skin, greenery, blue sky) and intermediate hues (e.g. orange, yellow-green). The third line represents the extreme points of the RGB (red, green, blue) colour system and CMY (cyan, magenta, yellow) colour system. The fourth line contains 6 patches of grey that can be used for calibration of hghtness and white balance. For the usage in our application we chose the X-Rite C olorChecker Passport (X-Rite, Ino., 2009a), shown in Figure 3, instead of the classical variant of ColorChecker since it better suits our requirements. This version of the colour chart is suitable for field work in geology since it ic smaller Shan the classical version and has a hard pi lasti c ca sing. Concerning the accuracy of colours one of the larger colour charts with more colour patches (e.g. ColorChecker Digital SG, IT8) -would be more appropriate for laboratory work. The advantage of a smaller format of the colour chart is that its size better suits the size of rock samples and thus enables us to capture the samples in a higher resolution. For many samples an evensmaller colour chart of 3 cm x 2 cm would be (convenient. The X-Rite ColorChecker Passport colour chart contains two additional calibration charts compared to the classic ColorChecker chart - a special section with a large grey patch for white balance and a section named Creative Enhancement Target (CET). CET contains 28 patches: 8 highly saturated colour patches, 2 lines of (5 patches for visual white balance and 4 vnry light grey and 4 very dark grey patches for detection of overexposure and underexposure. This colour chart is not meant for automatic colour nalibration, which may be the reason 252 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC why there is no data on official colour values of the patches available in the literature or on the internet. However, we have found unofficial spectrophotometric measures (Myers, 2010) which we used to help evaluate the calibration quality of our method. Detection of the ColorChecker colour chart -ASIFT algorithm Precise detection of patches on the ColorChecker is very important since the calibration process depends on the measured colour values. For detection of the ColorChecker colour chart we used Affine Scale Invariant Feature Transform or ASIFT (Yu & Morel, 2011). SIFT (Lowe, 2004) is a computer vision algorithm which extracts features that can be used for various tasks in computer vision, e.g. object detection (Lowe, 1999), panorama stitching (Agarwala et al., 2006), automatic 3D modelling (vergauwen & van Gool, 2006) and gesture recognition (scovanner et al., 2007). Features detected by SIFT are resistant to scaling, translation, and to some degree rotation. ASIFT is a simple extension of SIFT where combinations of rotation and shearing transformations are applied multiple times on the image. SIFT features are extracted from the transformed image and transformed back to the original image coordinate space. Using this process we get a larger number of features that are also more robust under affine transforms. According to a recommendation by Yu & Morel, 2011, it is sufficient to use 6 shears and rotations from 0° to 180° depending on degree of shearing - in all 42 transformations. Fig. 4.Visualization of ASIFT on a photograph of X-Rite ColorChecker Passport (right hand side) and reference X-Rite ColorChecker Passport colour patch image (upper left hand side). Fig. 3. X-Rite ColorChecker Passport colour calibration chart that is used by our application. Colour chart detection To detect a particular object with the ASIFT algorithm we need an image of the object, we then extract SIFT features from both images, the image where we want to detect the object and the image of the object. Detection is performed by finding the best correspondence between the SIFT features of both images. Figure 4 shows lines connecting the corresponding pairs of ASIFT points. Squares on the photo show the centre of the patches. On the bottom left we see the aligned image of the detected object (colour chart) and squares with averaged colours inside the detected patches. Computer aided method for colour calibration and analysis of digital rock photographs 253 The method is suffiri eirlOy gen eral to be used for other colour- charts as well. The only part wo would need to change io the colour chart image and the arrangement of the patches as hhey appear on a particular- colour chart. For the purpose of evaluating thr quality of caliboation we havr added the option to dotect the CET coloua chart on the ColorChecker Parsprrt. Colour calibrario n oh photographs The aim of photograph colour calibration is to bring the colour values oi the photograph ar close as possible to values we would moasure on the surfaces wo arophotographmg. Calibration could be attempted completely programmatically without the colour chart by extracting the necessary information from the metadata and the image itself (e.g. conditions under which the photograph was taken and the equipment used) and infer the actual colours in the photograph. Because this procedure cannot guarantee acruracy we have decided on calibration using a colour chart. Colour calibration can be done using ColorChecker colour calibration chart that is put in the photographed scene. To assure best results the lighting of both the colour chart and the rock should be as uniform as possible (X-Rite, Inc., 2009a) and with a sufficiently wide spectrum. We can achieve that by using additional lighting or the camera flash. If we use natural light the direction and the intensity of the light should be as much as possible similar on both the rock and the chart. During the calibration process Ohe application first dotecti the ColorChecker colour choet on the photograph. Thenaverage cotour values are extracted from the chart and the distances from the reference colour values for the chart ore calculated. Thus we get a calibration vector in CIE L ab colour space for each colour pa tch. The calibration could be done in another colour space as well but; CIE Lab is very suitable for this purpose because of its good perceptual uniformity. The issue of overfitting We are generalizing on the basis of a quite small amount of data, so we have to take care not to rverfit the algorithm (Hastie et al., 2009). With simple calibration methods overfitting may appear because of the uneven colour distances betwe en co1our patches, sin c e pa rts of the col our space represented by more patches are weighted more. When using more complex methods we also have to take care, that the algorithms do not transform the col ours in a -way that does not correspond to physical reality. In calibration with translation the overfitting was avoided by using leave-one-out cross validation (Hastie et al., 2009), where the colo ur patch, for which the value is being predicted, is not used in the prediction. In calibration with a lfnear combination some rrslfiance againsi averfilting os providad by the faat rhot tho parcheo oa tho CalorCheckrr chart contain both tha extieme and central points m tioe calaur apace, and. smoa the rpcte ir paaceptually unifarm, a finerr motiiod is nof likely tr cvoafto Calibration with trandation The first method for (colour calibration that we implemarted finds a single colour vector in the CIE Lab space, which minimizoc ohe CIE 4£0o datonae batween the avarago eolaur vetos on t;he detected eoleur patco-ao cef cnd the refarence values CQ. Uemg the ColoaChesker shart, we hcee n = 24 patches, bout the method works wtth any number of patches. C = (L, a, b= = = c + ia Where it it a vector which minimizes tha following expression: ! mint^AEriCorriCC^, CQ) t=i As mentioned, the CIE Lab space is not perfectly percepiuually uniform, furthermore, the photograph capturing process is not perfect and introduces various changes to the colour space (e.g. contrast, fringing0, over- or underexposure), which require more advanced methods of correction. However the method is srnple so we implemented it to compaee it with other methods. This mchhod can alss be used in conjunction with other mothodo, since it cannot skew the eolour space, however, it ¡should not Ice used after a cahbration method which is more oobust againtt overfitting. CaOibration with a weight ed average The method of calibrating with the weighted average of calibration vectors Cct,, computes the weighted average using; hwo weighting coefficients ite. The -value of the first; coefficient cs determined using an evolutionary algorithm beforecalibration, while the value of the second coefficignt dj(C) is a funation of Jthe distance between the colour being caaibrated C and the colour patch CCl. For- the first uik weights we have 3 ■ n normalized weights, which determine thg importance of each component (L, a, and b) of each colour patch. If the colour value of ssme patch deviates greatly from the reference value (e.g. because of a damaged patch, ever- or underexposure, shadows, partly occluded patch), or put another way: if the other patches offer a better calibration in the part oi the co lour opace the current patch gccupies, then its weight "will be smaller. These weights are determined before the calibration with an evolutio nary sea rch algorithm. 254 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC C = (L, a, b), C' = (V, a', b') CCi = (LCi, act, bed = CQ - CCt di(C) = 1 94( ' max? ±A£I4(C, CCJ L' = L + f t=i u¡ di (C) a' = a + add acÉ • u¿a • dj(C) í=i n b' = 6 + X ÓCí t=l l Tlie algorithm starts with all weights set to ~ and then iteratively makes random changes, and computes the fitness 'unction to see if the new ¡set of weighte is better than the previous one;. The fitness function works acaerding to the laave-one-out cress validation stretegy. Thie means the algorithm is used n times, and one patch is left out of the calibration aachtime. The value of the remaining patch is calibrated esch time, and the output of the fitness funetion sis the average of colour distances from Ohe calibrated patch colour value to the reference calotte value. The second weight coefficient cS(C) is a function of the colour being calibrated. The colour patches which are furthea away in the colour space are weighted less than those nearby. The CIE ¿eig formula was used, sinse the colour differences are expected to be large, which makes the use of CIE 4£ll inappropriate. Calibration with a linear combination This calibration method computes each calibrated component asa linear combination of the old componentvalues in CIE Lab. Again, the task is to find She coefficients where the distance between the calibrated patchee and their respective refeaence values is minimal. C = (L, a, ¿Oí ae = (+', a', b'e L' = L ■ uLl -e a • ua 1 + It ■ u^ a' = L uLi + a Ua2 + <& ub2 + u2 b' =l L • uL3 + a ■ uLj3 -I- b ■ ubu + u3 TTlie meaning of components a and b in CIE Lab is tibe balance between red and green, and yellow and blue. We can udd some moire strength to the method by choosing different coefficients for the po sitive and negative side of the a and b axes: ua n(«) un a > 0, a = 0, u! t tan a < 0h K Dn ó > 0, 0 b = 0, u¡2" b < 0; As shown later, this improves the results somewhat, but since it isstill a linear transformation there should beno problems with skewing the colour space. The exception would be if the colour value of some patch deviated greatly from the reference values. This could be avoided by leaving out the patches which deviate the most. However this could lead to overfitting, or bad calibration results in cases, where ¡some part of the colour space on the captured photograph really was quite far fromthe reference values. Tlie method for celibretion with a weighted average is more robust against this kind of problem. Apart from this, we have only noticed one more interesting gel itch, later found not to be limited to this method. The cyan patch found in the third row of the ColorChecker salibratisn chart has Lab valuee which Hall outside the range of coWours phesentable in the RGB colour- syctem which is ushd iii digital photography. This means there is some crlour clamping upon conversion from CIE Lab bock to RGB. We have noticedthis effect on an image which had strong JPEG compression artifacts, whech the clamping had amp lified. If the RGB colour system supported a -wider range, the oed somponent of RGB would need to tie negative, but Ohis issue is net too problematic, iince the CIE o dietcance between the; actual and clamped value is only 2.2, and the application performs the calculations and user readouts in the CIE Lab colour space, so the glltch was noticeable only on screan, and upon saving back to JPEG. User interface The application user interface is simple and contains only the neeessary compenents for- switt, accurate and repeatable colous analysis. The onterface was built using the Scala Swing library. Infigure 5 the original photograph can be seen on the left including ann otation points for the colour charts ColorChecker, and Cre ative Enhancement Target. On the right side the colour calibrated photo with some manually added annotations is shown. The results of colour analysis at these points and areas are presented in the text field on the right. Additionally the photograph metadata and annotation data can be taved to a file. To ease woeking with the calibeated photograph, we can choose to tade the original photograph. If the user only wants to check particular phetograph colour values, they can click on the desired points. If the shift; key is held when moving th e mouse pointer aroun d the ph otograph, the colour values under the mouse cursor are continually printed out on tha right. An area on the photograph can be selected holding the control key and drsgging the mouse. Tho application then prints tite average colour value and percentage of coverage oS individual Munsell colour values. In the onnotation mode colour values of currently selected posnts and areao are printed out on thie might side. Computer aided method for colour calibration and analysis of digital rock photographs 255 Fig. 5 User interface of the developed application. Results Measuring the accuracy of colour calibration A good colour calibration is necessary to precisely determine the colour values. Therefore we evaluated the accuracy of the calibration procedure. We estimated the accuracy with statistical analysis of deviations between measured and reference colour values of two colour charts. We first compiled a statistic for the ColorChecker colour chart. This could be problematic as this data also served as the basis of fitting the parameters for the calibration procedure. In the case of a too strong fit (overfitting), we would not be able to detect it. Therefore we chose to additionally evaluate the colour deviations on the upper eight patches of the Creative Enhancement Suite (CET) colour chart. We have to reiterate that the reference colour values used for CET colour chart are not provided by the colour chart manufacturer, which could cause deviations. However, the deviations should be small since the values we use were acquired with accurate spectrophotometric measuring (Myers, 2010). We used two sets of digital photographs for evaluation. The first set contains 40 different photographs taken under non-controlled conditions - outdoors (field work) and indoors - and therefore contains a mixture of different light conditions (direct sunlight, cloudy weather, indirect lighting in shadows, camera flash, indoor lighting etc.) taken with a variety of digital photographic cameras. The second set of photographs contains 10 digital photographs, which were taken using the geological sample collection of Faculty of Natural Sciences and Engineering, University of Ljubljana. This set of photographs was taken under good lighting conditions on a white surface using camera flash illumination. Both sides of the colour chart (ColorChecker and CET) were positioned and lit as consistently as possible in every photograph. Fig. 6. Boxplot of deviation from reference colour values (0) on ColorChecker (left) in CET (right) colour charts for photographs captured under outdoor field work conditions. 256 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC Fig. 7. Boxplot of deviation from reference colour values (0) on ColorChecker (left) in CET (right) colour charts for photographs captured under laboratory conditions. As we can see in figures 6 and 7 the colour calibration lowers deviations and distances in almost every case and thus enhances the quality of colour information. First column in the figures represents the distances of measured uncalibrated colour values from the reference values. Other columns show colour distances after different colour calibration procedures, which were presented in the colour calibration section. In the photos captured in non-controlled conditions we can see a large difference between the values shown on the left and right in Figure 6. This is likely the consequence of different illumination on the two colour charts in the photographs, therefore we once again stress the importance of uniform lighting, i.e. usage of additional lighting or camera flash when photographing. For photographs taken under laboratory conditions in figure 7 the colour deviations between detected and reference values are much lower and the interval is narrower. It is interesting that all values, even in the uncalibrated first column on the left graph in figure 7 are lower compared to the right graph in figure 7. This may be the consequence of deviation between the official values for ColorChecker colour chart and the unofficial values for the CET colour chart. On the basis of the above measurements of deviation from the reference values, we can assess that by using the proposed computer-aided method under good lighting conditions we can calibrate colours almost as precise as an average human being can differentiate between different shades of colours (Mahy et al., 1994). Moreover for photographs captured in non-controlled conditions, we can greatly improve the quality of colour information. Comparative analysis In the second part of the evaluation we compared the results of manual colour analysis of rock samples by students of geology using a Munsell Rock-color Chart. From the geological rock sample collection of Department of geology of Faculty of Natural Sciences and Engineering, University of Ljubljana, we selected 10 rock samples (Table 1) and photographed them on a level white surface using camera flash (Fig. 8). Captured images were colour calibrated with the second linear combination procedure, which performed best in the assessment. Then we selected and determined the colour values of representative parts of each sample using the application. Fig. 8. Rock samples that were colour analysed in the comparison experiment. With the help of eight volunteer geology students we conducted an experiment. We enumerated and put 10 rock samples on the laboratory table and we specified how many different colours have to be determined for each sample (Fig. 8). The students were instructed to determine the set number of colours based on the importance and colour coverage using their domain knowledge. The students had the Computer aided method for colour calibration and analysis of digital rock photographs 257 appropriate experiences for the task, since they have already been trained to determine colour using comparison methods in laboratory and outdoor field working conditions. It turned out that not every student determined the colours on the same part of the multi-coloured rock samples and consequently the order and colour labels did not match. The result is somewhat worse compared to the expected precision of colour value discrimination precision of the average human. The experiment has shown that the selection of measuring points on rock surface is subjective. In some cases it was difficult to infer which part of rock is described by a given colour value. Table 1 summarizes the determined colour labels for all samples. The last column shows the average of average CIE AE00* distance between the determined colour values in each group. Table 1. Results of manual comparative rock colours determination on selected rock samples. From high average distances between individual readings it is obvious the subjective selection of the points of observation/comparison by the observers. no. sample colour -mineral composition estimated compared colours, number of students with the same estimation in brackets average of average intermeasure distances in CIE white - calcite 5Y 8/1 (3), N8 (3), 5GY 8/1, N7 8.71 1 mineralised green - epidote 10Y 5/4 (5), 10Y 7/4 (2), 10Y 6/6 8.79 skarn - contact-metamorphic rock red - granate 10R 2/2 (2), 10R 3/4, 5YR 3/4, 5R 2/2, 10R 6/2 16.97 black - ore mineral magnetite N2 (5), N3 (2), 5Y 2/1 5.23 hidrothermaly altered fine-grained magmatic rock white - quartz 5Y 8/1 (2), N9 (2), 5B 9/1, 5G 8/1, N7, N8 11.88 2 dark green - chlorite 10GY 5/2 (3), 10G 4/2 (2), 10Y 4/2 8.65 light green - epidote 5GY 7/4 (3), 10Y 6/6 (2), 10Y 5/4, 5GY 7/2 10.39 mercury ore in carbonate host rock from the Idrija mine red - cinnabarite 5R 3/4 (4), 5R 2/6 (2), 5R 4/6 (2) 7.60 3 grey - dolomite 5Y 6/1 (4), 5Y 6/2, 5Y 4/1, N7, N5 10.96 black - pirobitumen N1 (4), 5R 3/4, 10YR 2/2, 5GY 4/1 14.80 brown - goethite N2, N3 (2), N4, 10YR 2/2 (2), 5YR 3/2 (2), 10.35 4 aluminium ore -bauxite yellow - lepidokrokite 10R 6/2, 5YR 5/6 (2), 10YR 6/6 (2), 10YR 8/6, 10YR 5/4, 5YR 2/2 20.22 red - hematite 5R 4/6, 10R 3/4 (5), 10R 8/2, 10R 4/6 15.13 5 red hematitized limestone red: hematite in limestone build of calcite; white: vein of pure calcite 10R 3/4 (3), 5R 4/6 (2), 5R 3/4 (2), 10R 5/4 8.76 6 chrome ore green - serpentinite 10Y 5/4 (3), 10Y 7/4 (2), 5Y 7/6, 5Y 4/4, 5Y 6/4 13.36 black - ore mineral chromite N2 (4), N1, 5Y 2/1, 5G 2/1 6,53 brown pigment- goethite 10R 6/6 (2), 10R 7/4 (5), 5R 6/6 5.81 7 aluminium ore yellow pigment - lepi-dokrokite 5Y 8/4, 10YR 8/6 (7) 2.17 red pigment - hematite 10R 4/6, 5R 6/6, 10R 3/4 (5), 10R 5/4 12.05 carbonate host rock mineralised with lead and zinc black - ore mineral galenite N5 (3), N4 (2), N3 (2), 5G 4/1 10.96 8 brown - ore mineral sphalerite 5Y 8/1 (5), 5GY 8/1 (2), N9 5.71 white - dolomite 5Y 7/2 (3), 5Y 6/1 (2), 5GY 8/1 (2) 8.18 9 silicified carbonate rock mineralised by zinc brown - ore mineral sphalerite 5Y 5/2, 10YR 6/6 (4), 5YR 3/4, 10YR 2/2, 5YR 5/6 18.75 white - dolomite partly replaced by quartz 5Y 8/1 (2), N5, N7, 5G 8/1, 10YR 4/2, 5Y 6/1 (2) 18.80 white - plagioclase N9 (7), 5Y 8/1 3.37 10 coarse - grained pink - K feldspath 5R 7/4, 10R 8/2, 5R 8/2, 5YR 8/4, 10R 7/4 (2), 5YR 6/4, 5YR 8/4 10.24 igneous rock grey - quartz N5 (2), N6 (2), N7 (3), 5Y 8/1 11.48 black - biotite N1 (4), N2 (3), 5G 2/1 5.45 258 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC Sample no. 3 is the only cut and polished sample. The values for red agree well, however for grey and black the students chose less saturated hues, i.e. purer grey and black. A possible explanation for this is that the surrounding red colour influenced the students' perception of grey and black. Such phenomena of human visual perception are acknowledged by Sharma & Bala, 2002. We chose sample no. 5 for its relatively uniform coloration and therefore we instructed the students to determine only one colour value - in this case the subjectivity of choosing the measuring location is smaller. Samples no. 4 and 9 proved to be problematic as the students chose many different colour values. Sample no. 9 was problematic for the application as well since it contains small fragments of brown mineral sphalerite which somewhat reflects light - in this case it would be better to photograph the sample without using the flash and in a very high resolution to be able to analyse individual fragments. It would be necessary to examine and determine the optimal conditions for photographing samples that are reflecting light to different degrees. Let us name a few other problems we noticed during the experiment. One of the students turned the colour chart the other way around and read the wrong colour values, however he noticed the mistake after finishing the first sample and corrected the results. One of the noted colour values was not a valid value in the Munsell system. Two of the students marked two different rock samples with the same number, however we managed to determine which sample they belong to in both cases by examining the remaining data. Some samples were missing a few of the colour values and there was one sample with one value more than the requested number of values. When transcribing the written data into the computer we made a few mistakes that were identified and corrected after proofreading. Colour analysis with the help of the application would solve most of the subjective causes for problems. If we count the number of measures for each sample we can see that every colour is on average represented by four different Munsell colour values. If all the students took the measures on the same points of the rock sample and if we eliminate some of the other errors that occurred in the data, the average would likely be reduced. However, it is necessary to stress that the students were motivated volunteers who did the colour determinations in a well-lit room. We believe that the values acquired during field work would be much more varied, since we have to take into account the weather, and changing light conditions. Discussion Estimation of colour value and colour coverage for multicoloured objects in geology is very subjective especially in field work due to lack of time and unpredictable weather and lighting conditions. Objectivity is higher when these parameters are estimated on the samples brought from field work to the laboratory, where there are fewer time constraints and the lighting conditions are better. Moreover there is no precipitation, humidity is low and there is less chance to make the colour chart dirty or otherwise degrade its quality. The presented computer application is useful in both environments. During field work it enables very quick acquisition of the observed object's colours information, while the analyses can be done later in the laboratory or office with the use of the proposed application when there is more time available. The computer application also substantially enhances and improves the work in the laboratory. We propose to include colour calibrated photographs into the archives along with the samples or other objects of observation. Further development of the application can take several directions. We can implement it as a web and/or mobile application suited for field work use. Digital photography is inexpensive and enables photographic documentation of all important rock outcrops on the route of field observation, which could result in several hundred observed outcrops and samples daily. With the synchronous capture of digital photographs of rocks outcrops and samples combined with the GPS coordinates the user can map rock colour variability in the area. In areas where rock colour is distinctive of a specific part of the lithostratigraphic succession (lithostratigraphic unit) we can use the quality rock colour information as basic lithology recognition parameters, which in turn enable us to construct geological maps together with the use of structural and tectonic elements. For further processing of the acquired data we can use additional statistical approaches (e.g. clustering) and with the help of crowdsourcing we can build a database containing colours of rock and mineral types, which could aid computer rock identification. The proposed method is most useful for recognition of lithostratigraphic units, which contain varieties of clastic sedimentary and mixed carbonate-clastic sedimentary rock varieties. We believe that most of such lithostratigraphic units could be distinguished and recognised on the basis of the proposed method of colour analysis. Conclusions Munsell Rock-color Chart and Munsell Soil-color Chart for soils have already been used for precise comparative determination of rock and mineral colours for some decades. Determining colour values of multicoloured rocks in the field with the manual method is very time consuming Computer aided method for colour calibration and analysis of digital rock photographs 259 and consequently expensive. This is especially so in detrimental weather conditions when colour charts could get wet and/or dirty, making comparison inconvenient and can severely degrade the quality of the standard chart used for comparison. Conventional colour charts are relatively expensive, so every additional purchase in order to replace a dirty chart is an additional unplanned cost. In search for the best compromise between time used for colour determination and quality of colour determination for multicoloured objects, each observer chooses their own set of representative points. This was found to be more or less subjective and did not necessarily result in colour values, which were representative for the observed outcrop or for a rock fragment, taking into account the surface area of a specific colour. Surface colour representation and coverage is often very subjectively estimated. Determination of colour surface coverage on the basis of a statistically representative number of evenly distributed points on the analysed surface is too time consuming and consequently too expensive and usually omitted. This results in subjectivity and an incorrect estimation of various visible rock characteristics. Digital cameras have become a standard tool for documenting geological and other field observations. Besides various other information found in digital photographs, they can be also used as an objective source of colour values and their areal coverage on the captured objects, if the digital photographs are properly calibrated. To provide fast, objective and repeatable colour values determination we have developed a computer application, which provides automatic colour calibration of digital photographs on the basis of a standard colour chart ColorChecker, systematically added onto the photographed surface. It automatically identifies colours within the Munsell colour system, and calculates colour surface/areal representativity coverage and logs the details of executed analyses (positions of measured points and areas saved along with calibrated images). For digital photograph colour calibration we implemented the detection of the ColorChecker and Creative Enhancement Suite colour charts, which are a part of the ColorChecker Passport produced by the X-Rite Company. It is easy to add support for any other models or types of colour charts, if needed, as the used approach for detection and calibration is general and can be used for any of them. We have implemented four methods for computer colour calibration, which use evolutionary algorithms to determine the best coefficients for each method. Methods for colour calibrations have improved the quality of colour information on practically all the digital photographs used in the assessment. In some test photographs, taken in non-controlled conditions, there was quite a big deviation of colour values from the reference values for the Creative Enhancement Target, which was not used in calibration (fig. 6). The deviation is likely a consequence of uneven natural lighting, so it is necessary that during the capture of the digital photographs, the colour chart and the outcrop, rock or any other object of photography, is as evenly illuminated as possible (e.g. by using camera flash). The test photographs were taken in very varied conditions on purpose, so the effectivity of the method could be tested. The assessment results of the colour calibration methods we implemented also show that under laboratory conditions the colour distances from reference colour values are low and around the limit which still can be recognised by human vision. For the photographs taken under non-controlled conditions the average colour distances are larger, but still quite low and within acceptable limits. Results of the comparison between the proposed automatic and the existing manual/comparative methods have shown, that manual/comparative colour determination is subjective and error-prone, even in stable laboratory conditions with no time pressure and with optimal lighting conditions. The user interface of the developed computer application enables colour value determination at selected points and calculation of colour value coverage and average colour of a broader selected area. Selected annotation points and areas, and the detail of calibration are saved inside the metadata of photographs, which enables full repeatability, and verifiability of the analyses at a later date. The described method is not limited to the field of geology and can be used in other areas, where colour determinations and colour areal representativity determination is a common task and objects of observation are of appropriate size to add a calibration colour chart into the scene, for example in soil science, archeology, biology, architecture, painting, art history etc. References Agarwala, A., Agrawala, M., cohen, M., salesin, D. & Szeliski, R. 2006: Photographing long scenes with multi-viewpoint panoramas. ACM Trans. Graph., 25/3: 853-861, doi:10.1145/1141911.1141966. Hastie, T., Tibshirani, R. & Friedman, J. 2009: The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition, Springer. Kelly, K. & Judd, D. 1976: Color: Universal Language and Dictionary of Names, U.S. Department of Commerce, National Bureau of Standards. 260 Matic: POTOČNIK, Bojan KLEMENC, Franc SOLINA & Uroš HERLEC Lowe, D. 2004: Distinctive Image Features from Scale-Invariant Keypoints. International Journal of Computer Vision, 60/2: 91-110, doi:10.1023/B:VISI.0000029664.99615.94. Lowe, D. 1999: Object recognition from local scale-invariant features. In 1150-1157, doi:10.1023/ B:VISI.0000029664.99615.94. MaHY, M., Van Eycken, L. & Oosterlinck, A. 1994: Evaluation of Uniform Color Spaces Developed after the Adoption of CIELAB and CIELUV. Color Research & Application, 19/2: 105-121, doi:10.1111/j.1520-6378.1994.tb00070.x. McCamy, C.S., Marcus, H. & Davidson, J.G. 1976: A color-rendition chart. J. Appl. Photogr. Eng., 2/3: 95-99. Munsell, A. 1905: A color notation, G. H. Ellis Company. Myers, R.D. 2010: ColorChecker Passport Technical Review, revision 3. RIT Munsell Color Science Laboratory Munsell Renotation Data. Internet: http://www.cis.rit. edu/research/mcsl2/online/munsell.php (3. 10. 2014) Ruiz, J.F. & Pereira, J. 2014: The colours of rock art. analysis of colour recording and communication systems in rock art research. Journal of Archaeological Science, 50: 338349, doi:10.1016/j.jas.2014.06.023. Schanda, J. 2007: Colorimetry: understanding the CIE system, Wiley. Scovanner, P., Ali, S. & Shah, M. 2007: A 3-dimensional sift descriptor and its application to action recognition. In: Proceedings of the 15th international conference on multimedia 357-360. MULTIMEDIA '07, New York, NY, USA: ACM, doi:10.1145/1291233.1291311. Sharma, G. & Bala, R. 2002: Digital Color Imaging Handbook, Taylor & Francis. Sharma, G., Wu, W. & Dalal, E.N. 2005: The CIEDE2000 color-difference formula: implementation notes, supplementary test data, and mathematical observations. Color research and application, 30/1: 21-30, doi:10.1002/col.20070. Van Hurkman, A. 2013: Color correction handbook: professional techniques for video and cinema 2nd ed., Berkeley, CA, USA: Peachpit Press. Vergauwen, M. & Van Gool, L. 2006: Web-based 3D reconstruction service. Mach. Vision Appl., 17/6: 411-426, doi:10.1007/s00138-006-0027-1. X-Rite, Inc. 2009a: ColorChecker Passport User Manual. Internet: http://www.xrite.com/doc-uments/manuals/en/ColorCheckerPassport_ User_Manual_en.pdf (3. 10. 2014) X-Rite, Inc. 2009b: Munsell Rock-color Charts with genuine Munsell color chips. X-Rite, Inc. 2009c: Munsell Soil-color Charts with genuine Munsell color chips. Yu, G. & Morel, J.M. 2011. ASIFT: An Algorithm for Fully Affine Invariant Comparison. Image Processing On Line 2011, doi:10.5201/ ipol.2011.my-asift.