{"id":1018,"date":"2014-04-25T12:37:20","date_gmt":"2014-04-25T16:37:20","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=1018"},"modified":"2019-11-01T11:03:48","modified_gmt":"2019-11-01T15:03:48","slug":"color-thresholder-app-in-r2014a","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2014\/04\/25\/color-thresholder-app-in-r2014a\/","title":{"rendered":"Color Thresholder App in R2014a"},"content":{"rendered":"<p>\r\nI had way too much fun this morning playing with the new Color Thresholder app (new in R2014a) in the Image Processing Toolbox, so I wanted to show it to you.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-initial.jpg\" alt=\"color-thresholder-initial\" width=\"600\" height=\"509\" class=\"alignnone size-full wp-image-1022\" \/>\r\n<\/p>\r\n\r\n<p>\r\nI've shown that picture of M&Ms in this blog before. A few years ago I used that image in a <a href=\"https:\/\/blogs.mathworks.com\/steve\/2011\/02\/04\/more-on-segmenting-in-a-b-space\/\">post about color segmentation in a*-b* space<\/a>. Here's the original image:\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2010\/mms.jpg\" alt=\"\" \/>\r\n<\/p>\r\n\r\n<p>\r\nYou can find the Color Thresholder app by clicking on the APPS tab.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/apps-tab.jpg\" alt=\"apps-tab\" width=\"600\" height=\"72\" class=\"alignnone size-full wp-image-1019\" \/>\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/ipcv-apps.jpg\" alt=\"ipcv-apps\" width=\"600\" height=\"105\" class=\"alignnone size-full wp-image-1034\" \/>\r\n<\/p>\r\n\r\n<p>\r\nI found the Color Thresholder to be a fun way to explore the a* coordinate (green to red\/magenta) and the b* coordinate (blue to yellow) in the L*a*b* color space. Some of the M&Ms have colors that can be segmented completely just using one of the color coordinates.  Below I have segmented the green ones just by selecting one of the peaks in the a* coordinate.\r\n<p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-green.jpg\" alt=\"color-thresholder-green\" width=\"665\" height=\"573\" class=\"alignnone size-full wp-image-1038\" \/>\r\n<\/p>\r\n\r\n<p>\r\nBut sometimes it is necessary to use both the a* and b* coordinates. The screen shot below demonstrates that one of the a* peaks corresponds to two different candy colors, orange and red.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-red-orange.jpg\" alt=\"color-thresholder-red-orange\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1027\" \/>\r\n<\/p>\r\n\r\n<p>\r\nTo get either orange or red, you have to narrow down the range in the b* coordinate.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-orange.jpg\" alt=\"color-thresholder-orange\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1024\" \/>\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-red-a.jpg\" alt=\"color-thresholder-red-a\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1025\" \/>\r\n<\/p>\r\n\r\n<p>\r\nIt turns out the color of my desk is different from all of the candy colors.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-desk.jpg\" alt=\"color-thresholder-desk\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1020\" \/>\r\n<\/p>\r\n\r\n<p>\r\nYou can use the opacity slider to let some of the rest of the image show through.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-opacity.jpg\" alt=\"color-thresholder-opacity\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1023\" \/>\r\n<\/p>\r\n\r\n<p>\r\nIf you want to automate the segmentation process, the Color Thresholder app can help you get started by generating some code for you.\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-export-function.jpg\" alt=\"color-thresholder-export-function\" width=\"600\" height=\"517\" class=\"alignnone size-full wp-image-1021\" \/>\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-generated-code.png\" alt=\"color-thresholder-generated-code\" width=\"575\" height=\"550\" class=\"alignnone size-full wp-image-1043\" \/>\r\n<\/p>\r\n\r\n<p>\r\nThis post has been kind of hard to write! There was a lot of fooling around with screen captures, and it's hard to do the app justice in this format. I just might have to learn how to do blog videos like <a href=\"https:\/\/blogs.mathworks.com\/videos\/\">Doug does<\/a>.\r\n<\/p>\r\n\r\n<p>\r\nIf you have ideas for other interactive image processing apps you'd like to see, post a comment here and I'll make sure the team sees it.\r\n<\/p>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/color-thresholder-generated-code.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nI had way too much fun this morning playing with the new Color Thresholder app (new in R2014a) in the Image Processing Toolbox, so I wanted to show it to you.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nI've shown that picture... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2014\/04\/25\/color-thresholder-app-in-r2014a\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[114,390,112,116,1081],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1018"}],"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=1018"}],"version-history":[{"count":16,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1018\/revisions"}],"predecessor-version":[{"id":1048,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1018\/revisions\/1048"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=1018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=1018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=1018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}