{"id":8787,"date":"2017-08-04T09:00:01","date_gmt":"2017-08-04T13:00:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8787"},"modified":"2017-08-02T21:36:46","modified_gmt":"2017-08-03T01:36:46","slug":"impressionism","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/08\/04\/impressionism\/","title":{"rendered":"Impressionism"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/62298-impressionism\">impressionism<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/6001794\">David Mills<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>My pick this week is a fun one that takes your images and transforms them into how they may have looked if painted by an impressionist.  Here are some of my photos impressionized.  I&#8217;ll use the <a title=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/imagedatastore.html (link no longer works)\"><tt>imageDatastore<\/tt><\/a> and a custom <i>&#8216;ReadFcn&#8217;<\/i> to do everything in one shot for me.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">\r\n<span style=\"color: #0000FF\">function<\/span> Iimp = impressionizeAndCompare(filename)\r\nimshow(filename)\r\ntitle(<span style=\"color: #A020F0\">'Original'<\/span>)\r\nsnapnow\r\nIimp = impressionism(filename);\r\nimshow(Iimp)\r\ntitle(<span style=\"color: #A020F0\">'Impressionized'<\/span>)\r\nsnapnow\r\n<span style=\"color: #0000FF\">end<\/span>\r\n<\/pre>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imds = imageDatastore(pwd,<span style=\"color: #A020F0\">'ReadFcn'<\/span>,@impressionizeAndCompare);\r\nreadall(imds);<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_01.png\"> <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_02.png\"> <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_03.png\"> <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_04.png\"> <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_05.png\"> <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_06.png\"> <\/p>\n<p>David has provided a bunch of options for tuning how the painting looks as well.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">Iimp = impressionism(<span style=\"color: #A020F0\">'membrane.png'<\/span>, <span style=\"color: #A020F0\">'brush sizes'<\/span>, [16 8 4], <span style=\"color: #0000FF\">...<\/span>\r\n           <span style=\"color: #A020F0\">'max length'<\/span>, 80, <span style=\"color: #A020F0\">'blur factor'<\/span>, 1.5);\r\nimshow(Iimp)<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_07.png\"> <\/p>\n<p>I&#8217;m sure marketing won&#8217;t be too fond of that.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">Iimp = impressionism(<span style=\"color: #A020F0\">'dsfadf.png'<\/span>, <span style=\"color: #A020F0\">'brush sizes'<\/span>, [16 8 4], <span style=\"color: #A020F0\">'max length'<\/span>, 80);\r\nimshow(Iimp)<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_08.png\"> <\/p>\n<p>My only suggestion for David is that the function should take a matrix as input as well as a filename (similar to imshow).<br \/>\n       The function takes a while to compute on large images and by only taking the filename, I need to first read in the image,<br \/>\n      <tt>imresize<\/tt> it, write it out, and then call impressionism.\n   <\/p>\n<h3>Comments<a name=\"5\"><\/a><\/h3>\n<p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8787#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/62298-impressionism#comments\">comment<\/a> for David.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_27d7fd21fe564107b5994bbec674a5da() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='27d7fd21fe564107b5994bbec674a5da ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 27d7fd21fe564107b5994bbec674a5da';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_27d7fd21fe564107b5994bbec674a5da()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017b<\/p>\n<\/div>\n<p><!--\n27d7fd21fe564107b5994bbec674a5da ##### SOURCE BEGIN #####\n%% Impressionism\n%\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/62298-impressionism impressionism> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/6001794 David Mills>.\n% \n\n%% \n% My pick this week is a fun one that takes your images and transforms them\n% into how they may have looked if painted by an impressionist.  David has\n% given us control over quite a few parameters.  Here's some of my photos\n% impressionized.  I'll use the\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/imagedatastore.html\n% |imageDatastore|> and a custom _'ReadFcn'_ to do everything in one shot\n% for me.\n%\n% <include>impressionizeAndCompare.m<\/include>\n\nimds = imageDatastore(pwd,'ReadFcn',@impressionizeAndCompare);\nreadall(imds);\n\n%% \n% David has provide a bunch of options for tuning how the painting looks as\n% well.\nIimp = impressionism('membrane.png', 'brush sizes', [16 8 4], ...\n           'max length', 80, 'blur factor', 1.5);\nimshow(Iimp)\n%%\n% I'm sure marketing won't be too fond of that.\nIimp = impressionism('dsfadf.png', 'brush sizes', [16 8 4], 'max length', 80);\nimshow(Iimp)\n\n%%\n% My only suggestion for David is that the function should take a matrix as\n% input as well as a filename (similar to imshow).  The function takes a\n% while to compute on large images and by only taking the filename, I need\n% to first read in the image, |imresize| it, write it out, and then call\n% impressionism.\n\n\n%% Comments\n% \n% Give it a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8787#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/62298-impressionism#comments\n% comment> for David.\n%\n##### SOURCE END ##### 27d7fd21fe564107b5994bbec674a5da\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainimpressionism\/mainimpressionism_01.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Sean&#8216;s pick this week is impressionism by David Mills.<\/p>\n<p>My pick this week is a fun one that takes your images and transforms them into how they may have looked if painted by an&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/08\/04\/impressionism\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8787"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8787"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8787\/revisions"}],"predecessor-version":[{"id":8794,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8787\/revisions\/8794"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}