{"id":282,"date":"2009-08-18T17:27:59","date_gmt":"2009-08-18T21:27:59","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/2009\/08\/18\/moving-toolbox-functions-into-matlab\/"},"modified":"2019-10-28T16:56:05","modified_gmt":"2019-10-28T20:56:05","slug":"moving-toolbox-functions-into-matlab","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2009\/08\/18\/moving-toolbox-functions-into-matlab\/","title":{"rendered":"Moving toolbox functions into MATLAB"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>I'm sorry to have disappeared off the blogging map the last couple of weeks. I got involved in some projects that needed many\r\n      hours of uninterrupted, focused time, which somehow doesn't mesh well with keeping up with the blog.  ;-)\r\n   <\/p>\r\n   <p>Last week <a href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/30\/five-years-of-image-processing-toolbox-changes\/#comment-22058\">StephenLL commented<\/a> on my <a href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/07\/30\/five-years-of-image-processing-toolbox-changes\/\">\"Five years of Image Processing Toolbox changes\" post<\/a>. Stephen said he'd like to see the function <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/toolbox\/images\/padarray.html\"><tt>padarray<\/tt><\/a> moved into MATLAB.\r\n   <\/p>\r\n   <p>I think that's a reasonable request.<\/p>\r\n   <p>There have been several cases in the past when we have moved Image Processing Toolbox functionality into MATLAB.<\/p>\r\n   <p>The first case was the image file reading and writing functions.  When Image Processing Toolbox version 1.0 shipped in 1993,\r\n      it included several pairs of functions for reading and writing image formats: <tt>tiffread<\/tt>, <tt>tiffwrite<\/tt>, <tt>bmpread<\/tt>, <tt>bmpwrite<\/tt>, etc.  Pretty soon, users started complaining that we were charging them for a toolbox when all they wanted to do was read\r\n      or write a TIFF file.  So we decided to move the functionality into MATLAB.  Based on our experience with the original functions,\r\n      we also decided to present the functionality with redesigned interfaces.  For example, we learned that it was frequently useful\r\n      to be able to read the metadata from an image file without actually reading the image pixels.  The new image I\/O functions\r\n      were <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imread.html\"><tt>imread<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imwrite.html\"><tt>imwrite<\/tt><\/a>, and <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imfinfo.html\"><tt>imfinfo<\/tt><\/a>, and they shipped with MATLAB 5.0 in 1997.\r\n   <\/p>\r\n   <p>A simpler MATLAB move, similar to what Stephen is suggesting for <tt>padarray<\/tt>, happened a little bit later with <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/circshift.html\"><tt>circshift<\/tt><\/a>.  This is one of the earliest cases I can remember where an Image Processing Toolbox function moved without modification\r\n      into MATLAB.  In this case, the first opportunity to ship the function was in a toolbox release, but it was written with the\r\n      idea that it might go into MATLAB at some point.\r\n   <\/p>\r\n   <p>The Image Processing Toolbox function <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/ind2rgb.html\"><tt>ind2rgb<\/tt><\/a> moved into MATLAB a year or two after MATLAB 5.0.  The driving factor here was the newly added ability to put image data\r\n      onto user interface buttons in Handle Graphics.  Users would read an indexed image from an indexed image file, for example,\r\n      but then get stuck because the button wouldn't take the image data in indexed form.\r\n   <\/p>\r\n   <p>The function <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/ref\/rgb2ind.html\"><tt>rgb2ind<\/tt><\/a> eventually found its way from the toolbox into MATLAB also, but not until the R2009a release earlier this year.  This change\r\n      was motivated in part by the reintroduction of GIF format support a couple of years ago.  Users wanted to write GIF files,\r\n      but the GIF format supports only indexed images, and MATLAB users without the Image Processing Toolbox found it difficult\r\n      to convert their truecolor images to indexed form.\r\n   <\/p>\r\n   <p>Moving <tt>rgb2ind<\/tt> was actually a fairly complicated move.  Conversion to indexed format is a complex calculation, and <tt>rgb2ind<\/tt> called several other Image Processing Toolbox functions to do portions of the work.  So all of these functions moved over\r\n      to MATLAB together with <tt>rgb2ind<\/tt>.\r\n   <\/p>\r\n   <p>I wrote the original version of <tt>padarray<\/tt> and figured it might be a candidate for moving into MATLAB at some point.  I can't really say for sure, though, whether and\r\n      when that might happen.  Such a function move affects product tests, reference pages, release notes, and so it requires coordination\r\n      from several people and maybe a day or two of person-time.  I suspect also that the current implementation may have some dependencies\r\n      on other Image Processing Toolbox utility functions, so these dependencies would need to be resolved. It's not a huge amount\r\n      of time, but then we never seem to have enough time to do everything we want to do with the product.\r\n   <\/p>\r\n   <p>Anyway, thanks again, Stephen, for the suggestion.<\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_a4782c9b36d94d2ab47b545d1a14a7e4() {\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='a4782c9b36d94d2ab47b545d1a14a7e4 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a4782c9b36d94d2ab47b545d1a14a7e4';\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        author = 'Steve Eddins';\r\n        copyright = '';\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 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');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \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_a4782c9b36d94d2ab47b545d1a14a7e4()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.8<br><\/p>\r\n<\/div>\r\n<!--\r\na4782c9b36d94d2ab47b545d1a14a7e4 ##### SOURCE BEGIN #####\r\n%%\r\n% I'm sorry to have disappeared off the blogging map the last couple of weeks. I\r\n% got involved in some projects that needed many hours of uninterrupted, focused\r\n% time, which somehow doesn't mesh well with keeping up with the blog.  ;-)\r\n%\r\n% Last week <https:\/\/blogs.mathworks.com\/steve\/2009\/07\/30\/five-years-of-image-processing-toolbox-changes\/#comment-22058 \r\n% StephenLL commented> on my \r\n% <https:\/\/blogs.mathworks.com\/steve\/2009\/07\/30\/five-years-of-image-processing-toolbox-changes\/ \r\n% \"Five years of Image Processing Toolbox\r\n% changes\" post>. Stephen said he'd like to see the function \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/toolbox\/images\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/toolbox\/images\/padarray.html \r\n% |padarray|>\r\n% moved into MATLAB.\r\n%\r\n% I think that's a reasonable request.\r\n%\r\n% There have been several cases in the past when we have moved Image Processing\r\n% Toolbox functionality into MATLAB.\r\n%\r\n% The first case was the image file reading and writing functions.  When Image\r\n% Processing Toolbox version 1.0 shipped in 1993, it included several pairs of\r\n% functions for reading and writing image formats: |tiffread|, |tiffwrite|,\r\n% |bmpread|, |bmpwrite|, etc.  Pretty soon, users started complaining that we\r\n% were charging them for a toolbox when all they wanted to do was read or write a\r\n% TIFF file.  So we decided to move the functionality into MATLAB.  Based on our \r\n% experience with the original functions, we also decided to present the\r\n% functionality with redesigned interfaces.  For example, we learned that it was\r\n% frequently useful to be able to read the metadata from an image file without\r\n% actually reading the image pixels.  The new image I\/O functions were \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imread.html \r\n% |imread|>,\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imwrite.html \r\n% |imwrite|>, and \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/imfinfo.html \r\n% |imfinfo|>, and they shipped with MATLAB 5.0 in 1997.\r\n%\r\n% A simpler MATLAB move, similar to what Stephen is suggesting for |padarray|,\r\n% happened a little bit later with \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/circshift.html \r\n% |circshift|>.  This is one of the earliest\r\n% cases I can remember where an Image Processing Toolbox function moved without\r\n% modification into MATLAB.  In this case, the first opportunity to ship the\r\n% function was in a toolbox release, but it was written with the idea that it\r\n% might go into MATLAB at some point.\r\n%\r\n% The Image Processing Toolbox function \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/index.html?\/access\/helpdesk\/help\/releases\/R2009a\/techdoc\/ref\/ind2rgb.html \r\n% |ind2rgb|> moved into MATLAB a year or\r\n% two after MATLAB 5.0.  The driving factor here was the newly added ability to put image\r\n% data onto user interface buttons in Handle Graphics.  Users would read an\r\n% indexed image from an indexed image file, for example, but then get stuck\r\n% because the button wouldn't take the image data in indexed form.\r\n%\r\n% The function \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2009a\/techdoc\/ref\/rgb2ind.html \r\n% |rgb2ind|> eventually found its way from the toolbox into MATLAB\r\n% also, but not until the R2009a release earlier this year.  This change was\r\n% motivated in part by the reintroduction of GIF format support a couple of\r\n% years ago.  Users wanted to write GIF files, but the GIF format supports only\r\n% indexed images, and MATLAB users without the Image Processing Toolbox found it\r\n% difficult to convert their truecolor images to indexed form.\r\n%\r\n% Moving |rgb2ind| was actually a fairly complicated move.  Conversion to indexed\r\n% format is a complex calculation, and |rgb2ind| called several other Image\r\n% Processing Toolbox functions to do portions of the work.  So all of these\r\n% functions moved over to MATLAB together with |rgb2ind|.\r\n%\r\n% I wrote the original version of |padarray| and figured it might be a candidate\r\n% for moving into MATLAB at some point.  I can't really say for sure, though,\r\n% whether and when that might happen.  Such a function move affects product\r\n% tests, reference pages, release notes, and so it requires coordination from\r\n% several people and maybe a day or two of person-time.  I suspect also that the\r\n% current implementation may have some dependencies on other Image Processing\r\n% Toolbox utility functions, so these dependencies would need to be resolved.\r\n% It's not a huge amount of time, but then we never seem to have enough time to\r\n% do everything we want to do with the product.\r\n%\r\n% Anyway, thanks again, Stephen, for the suggestion.\r\n##### SOURCE END ##### a4782c9b36d94d2ab47b545d1a14a7e4\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   I'm sorry to have disappeared off the blogging map the last couple of weeks. I got involved in some projects that needed many\r\n      hours of uninterrupted, focused time, which somehow doesn't... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2009\/08\/18\/moving-toolbox-functions-into-matlab\/\">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":[673,675,434,332,76,164,384,344,627,669,671],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/282"}],"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=282"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":3649,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/282\/revisions\/3649"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}