{"id":4189,"date":"2020-09-30T10:30:55","date_gmt":"2020-09-30T14:30:55","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=4189"},"modified":"2020-09-30T10:30:55","modified_gmt":"2020-09-30T14:30:55","slug":"how-to-detect-an-x-rite-colorchecker-chart","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2020\/09\/30\/how-to-detect-an-x-rite-colorchecker-chart\/","title":{"rendered":"How to Detect an X-Rite&reg; ColorChecker&reg; Chart"},"content":{"rendered":"<div class=\"content\"><p>When I saw this picture, I was really tempted to take it into the local garden nursery and ask them how to keep color checker charts out of my rhododendrons.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/colorCheckerTestImage-with-credit.jpg\" alt=\"\"> <\/p><p>No, no, this post is not really about protecting gardens against unusual invaders. I was looking over the just-released R2020b Image Processing Toolbox, and I noticed that a number of color science related features made it into the release. Since I was posting about color a couple of months ago, I thought I would highlight some of these new features here. Today, I'll start with a function that can detect the location of an X-Rite&reg; ColorChecker&reg; chart into the workspace.<\/p><p>First, let's read our test image. This file contains the image shown above.<\/p><pre class=\"codeinput\">A = imread(<span class=\"string\">'colorCheckerTestImage-with-credit.jpg'<\/span>);\r\n<\/pre><p>Next, create a <tt>colorChecker<\/tt> object from the image.<\/p><pre class=\"codeinput\">chart = colorChecker(A)\r\n<\/pre><pre class=\"codeoutput\">\r\nchart = \r\n\r\n  colorChecker with properties:\r\n\r\n                 Image: [1024&times;1541&times;3 uint8]\r\n    RegistrationPoints: [4&times;2 double]\r\n             ColorROIs: [24&times;1 struct]\r\n\r\n<\/pre><p>When created, the <tt>colorChecker<\/tt> object searches to find the position of the color checker chart in the image. The optional <tt>Downsample<\/tt> and <tt>Sensitivity<\/tt> parameters control some aspects of the automatic detection.<\/p><p>The <tt>displayChart<\/tt> function shows the image and places markers and numbers to identify the detected chart corners (called \"registration points\") and numbered color squares.<\/p><pre class=\"codeinput\">displayChart(chart)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/CreateColorCheckerChartFromTestImageExample_01.png\" alt=\"\"> <pre class=\"codeinput\">axis([725 1350 430 850])\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/CreateColorCheckerChartFromTestImageExample_02.png\" alt=\"\"> <p>The <tt>measureColor<\/tt> function produces a table containing the measured values of the detected color chart squares, together with their reference values. It also includes $\\Delta_E$, a measure of perceptual color difference.<\/p><pre class=\"codeinput\">T = measureColor(chart)\r\n<\/pre><pre class=\"codeoutput\">\r\nT =\r\n\r\n  24&times;9 table\r\n\r\n    ROI         Color          Measured_R    Measured_G    Measured_B    Reference_L    Reference_a    Reference_b    Delta_E\r\n    ___    ________________    __________    __________    __________    ___________    ___________    ___________    _______\r\n\r\n     1     {'DarkSkin'    }       160           128           119           37.54          14.37          14.92       19.817 \r\n     2     {'LightSkin'   }       229           200           191           64.66          19.27           17.5       22.587 \r\n     3     {'BlueSky'     }       146           191           241           49.32          -3.82         -22.54       27.312 \r\n     4     {'Foliage'     }       130           161           117           43.46         -12.74          22.72       20.404 \r\n     5     {'BlueFlower'  }       175           187           248           54.94           9.61         -24.79       23.073 \r\n     6     {'BluishGreen' }       155           232           226           70.48         -32.26          -0.37       18.284 \r\n     7     {'Orange'      }       255           161            99           62.73          35.83           56.5       16.114 \r\n     8     {'PurplishBlue'}       130           164           254           39.43          10.75         -45.17       28.889 \r\n     9     {'ModerateRed' }       252           146           160           50.57          48.64          16.67       23.601 \r\n    10     {'Purple'      }       139           118           175            30.1          22.54         -20.87       24.672 \r\n    11     {'YellowGreen' }       187           226           110           71.77         -24.13          58.19        15.21 \r\n    12     {'OrangeYellow'}       241           193            78           71.51          18.24          67.37       13.952 \r\n    13     {'Blue'        }        96           131           255           28.37          15.42          -49.8        33.34 \r\n    14     {'Green'       }       118           209           130           54.38         -39.72          32.27       22.461 \r\n    15     {'Red'         }       234           116           114           42.43          51.05          28.62        21.87 \r\n    16     {'Yellow'      }       241           227           105            81.8           2.67          80.41       23.495 \r\n    17     {'Magenta'     }       241           143           221           50.63          51.28         -14.12       23.967 \r\n    18     {'Cyan'        }        94           206           247           49.57         -29.71         -28.32       28.558 \r\n    19     {'White'       }       251           255           255           95.19          -1.03           2.93       5.6635 \r\n    20     {'Neutral8'    }       229           239           246           81.29          -0.57           0.44       13.655 \r\n    21     {'Neutral6.5'  }       203           218           225           66.89          -0.75          -0.06       20.166 \r\n    22     {'Neutral5'    }       165           179           189           50.76          -0.13           0.14        22.69 \r\n    23     {'Neutral3.5'  }       123           136           148           35.63          -0.46          -0.48       21.844 \r\n    24     {'Black'       }        72            83            97           20.64           0.07          -0.46       16.965 \r\n\r\n<\/pre><p>Now I just need to figure out how to keep these things out of my garden.<\/p><p><i>This post was adapted from the example \"Create ColorChecker Chart from Test Image\" in the <a href=\"https:\/\/www.mathworks.com\/help\/images\/ref\/colorchecker.html\">documentation<\/a> for <tt>colorChecker<\/tt>.<\/i><\/p><p><i>Copyright 2020 The MathWorks, Inc.<\/i><\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_3ae07d6d98064be6a08acdcb7b726895() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='3ae07d6d98064be6a08acdcb7b726895 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 3ae07d6d98064be6a08acdcb7b726895';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2020 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_3ae07d6d98064be6a08acdcb7b726895()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2020b<br><\/p><\/div><!--\r\n3ae07d6d98064be6a08acdcb7b726895 ##### SOURCE BEGIN #####\r\n%% How to Detect an X-Rite(R) ColorChecker Chart\r\n% \r\n% When I saw this picture, I was really tempted to take it into the local\r\n% garden nursery and ask them how to keep color checker charts out of my\r\n% rhododendrons.\r\n% \r\n% <<https:\/\/blogs.mathworks.com\/steve\/files\/colorCheckerTestImage-with-credit.jpg>>\r\n%\r\n% No, no, this post is not really about protecting gardens against unusual\r\n% invaders. I was just looking over the just-released R2020b Image\r\n% Processing Toolbox, and I noticed that a number of color science related\r\n% features made it into the release. Since I was posting about color a\r\n% couple of months ago, I thought I would highlight some of them here.\r\n% Today, I'll start with a function that can detect the location of an\r\n% X-Rite\u00ae ColorChecker\u00ae chart into the workspace. \r\n%\r\n% First, let's read our test image. This file contains the image shown\r\n% above.\r\n\r\nA = imread('colorCheckerTestImage-with-credit.jpg');\r\n\r\n%% \r\n% Next, create a |colorChecker| object from the image.\r\n\r\nchart = colorChecker(A)\r\n\r\n%%\r\n% When created, the |colorChecker| object searches to find the position of\r\n% the color checker chart in the image. The optional |Downsample| and\r\n% |Sensitivity| parameters control some aspects of the automatic detection.\r\n%\r\n% The |displayChart| function shows the image and places markers and\r\n% numbers to identify the detected chart corners (called \"registration\r\n% points\") and numbered color squares.\r\n\r\ndisplayChart(chart)\r\n\r\n%%\r\naxis([725 1350 430 850])\r\n\r\n%%\r\n% The |measureColor| function produces a table containing the measured\r\n% values of the detected color chart squares, together with their reference\r\n% values. It also includes $\\Delta_E$, a measure of perceptual color\r\n% difference.\r\n\r\nT = measureColor(chart)\r\n\r\n%%\r\n% Now I just need to figure out how to keep these things out of my garden.\r\n\r\n%%\r\n% _This post was adapted from the example \"Create ColorChecker Chart from\r\n% Test Image\" in the\r\n% <https:\/\/www.mathworks.com\/help\/images\/ref\/colorchecker.html\r\n% documentation> for |colorChecker|._\r\n\r\n%% \r\n% _Copyright 2020 The MathWorks, Inc._\r\n##### SOURCE END ##### 3ae07d6d98064be6a08acdcb7b726895\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/steve\/files\/CreateColorCheckerChartFromTestImageExample_02.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>When I saw this picture, I was really tempted to take it into the local garden nursery and ask them how to keep color checker charts out of my rhododendrons. No, no, this post is not really about... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2020\/09\/30\/how-to-detect-an-x-rite-colorchecker-chart\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":4199,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4189"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=4189"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4189\/revisions"}],"predecessor-version":[{"id":4197,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4189\/revisions\/4197"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media\/4199"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=4189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=4189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=4189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}