{"id":200,"date":"2008-03-17T14:27:29","date_gmt":"2008-03-17T18:27:29","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/2008\/03\/17\/multidimensional-image-processing\/"},"modified":"2019-10-24T13:59:11","modified_gmt":"2019-10-24T17:59:11","slug":"multidimensional-image-processing","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2008\/03\/17\/multidimensional-image-processing\/","title":{"rendered":"Multidimensional Image Processing"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>Every so often someone asks in comp.soft-sys.matlab for a \"function like Image Processing Toolbox function <tt>foobar<\/tt> that works in 3-D.\"  If I happen to see the post, I will follow up, explaining that <tt>foobar<\/tt> itself works just fine in 3-D.\r\n   <\/p>\r\n   <p>So in case some blog readers have been looking for a \"3-D version of <tt>foobar<\/tt>,\" I thought I'd mention it here.\r\n   <\/p>\r\n   <p>In the late 1990s we started hearing about requests for three-dimensional image processing support.  Then on some customer\r\n      visits in 2000 we heard some demand for <i>four-dimensional<\/i> support!  As a result, the major Image Processing Toolbox upgrade in 2001 (version 3.0) added arbitrary dimension support\r\n      to the toolbox.\r\n   <\/p>\r\n   <p>Many Image Processing Toolbox functions implement mathematical operations (such as convolution) that are perfectly well defined\r\n      in multidimensional spaces.  So our strategy was to go ahead and implement multidimensional support for all such functions.\r\n   <\/p>\r\n   <p>The meaning of the higher dimensions varies with the application and the data. With volumetric data (pixels become \"voxels\"),\r\n      the 3rd dimension is spatial, just like the first two.  Sometimes a higher dimension is time, or sequence number.  And sometimes\r\n      a higher dimension is spectral, as in color images or multispectral imagery.\r\n   <\/p>\r\n   <p>At some point after 2001, we began to realize that users weren't discovering the multidimensional capability of the toolbox.\r\n       Our first attempt to rectify that problem came when we added documentation sections explaining how to use toolbox functions\r\n      to process sequences.  (See \"Working with Sequences\" in the Users Guide.)  Through a kind of happy mathematical coincidence, it turns out that image processing operators working\r\n      in higher dimensions often just do \"the right thing\" when you have an image sequence represented in MATLAB as a three-dimensional\r\n      array.\r\n   <\/p>\r\n   <p>Let me explain that statement.  Suppose you have a 640-by-480-by-100 array, representing 100 images in a sequence.  And suppose\r\n      you want to filter each image in the sequence with the same filter.  Well, it turns out that multidimensional convolution\r\n      of a 640-by-480-by-100 input with a \"flat\" filter (that is, an M-by-N-by-1 filter) is exactly equivalent to filtering each\r\n      image in the sequence independently.\r\n   <\/p>\r\n   <p>For many users, though, this wasn't at all obvious, even if they did discover the multidimensional capability of many of the\r\n      functions.  So that's what led to the \"Working with Sequences\" section in the doc.  But the multidimensional functions can\r\n      also handle volumetric processing, or other multidimensional applications.\r\n   <\/p>\r\n   <p>Still, multidimensional support remains somewhat \"hidden\" in the doc.  Here's where you can almost always find it: Look in\r\n      the \"Class Support\" section of a function's reference page.  For example, here's what the Class Support section for <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/images\/index.html\"><tt>watershed<\/tt><\/a> says:\r\n   <\/p>\r\n   <p>\"A can be a numeric or logical array of any dimension, and it must be nonsparse.\"<\/p>\r\n   <p>Whenever you see that \"of any dimension\" phrase, you'll know that the function offers multidimensional support.<\/p>\r\n   <p>PS.  Don't ask me to send you the code for <tt>foobar<\/tt>.  I lost it.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_511341e586e24afd97571929d8826b46() {\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='511341e586e24afd97571929d8826b46 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 511341e586e24afd97571929d8826b46';\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 = 'Copyright 2008 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 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_511341e586e24afd97571929d8826b46()\"><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.6<br><\/p>\r\n<\/div>\r\n<!--\r\n511341e586e24afd97571929d8826b46 ##### SOURCE BEGIN #####\r\n%%\r\n% Every so often someone asks in comp.soft-sys.matlab for a \"function like Image\r\n% Processing Toolbox function |foobar| that works in 3-D.\"  If I happen to see the\r\n% post, I will follow up, explaining that |foobar| itself works just fine in 3-D.\r\n%\r\n% So in case some blog readers have been looking for a \"3-D version of |foobar|,\"\r\n% I thought I'd mention it here.\r\n%\r\n% In the late 1990s we started hearing about requests for three-dimensional image\r\n% processing support.  Then on some customer visits in 2000 we heard some demand\r\n% for _four-dimensional_ support!  As a result, the major Image Processing\r\n% Toolbox upgrade in 2001 (version 3.0) added arbitrary dimension support to the toolbox.\r\n%\r\n% Many Image Processing Toolbox functions implement mathematical operations\r\n% (such as convolution) that are perfectly well defined in multidimensional\r\n% spaces.  So our strategy was to go ahead and implement multidimensional\r\n% support for all such functions.\r\n%\r\n% The meaning of the higher dimensions varies with the application and the data.\r\n% With volumetric data (pixels become \"voxels\"), the 3rd dimension is spatial,\r\n% just like the first two.  Sometimes a higher dimension is time, or sequence\r\n% number.  And sometimes a higher dimension is spectral, as in color images or\r\n% multispectral imagery.\r\n%\r\n% At some point after 2001, we began to realize that users weren't discovering\r\n% the multidimensional capability of the toolbox.  Our first attempt to rectify\r\n% that problem came when we added documentation sections explaining how to use\r\n% toolbox functions to process sequences.  (See \r\n% <https:\/\/www.mathworks.com\/help\/images\/index.htmlf14-17682.html \r\n% \"Working with Sequences\"> in the Users Guide.)  Through a kind of happy\r\n% mathematical coincidence, it turns out that image processing operators working\r\n% in higher dimensions often just do \"the right thing\" when you have an image\r\n% sequence represented in MATLAB as a three-dimensional array.\r\n%\r\n% Let me explain that statement.  Suppose you have a 640-by-480-by-100 array,\r\n% representing 100 images in a sequence.  And suppose you want to filter each\r\n% image in the sequence with the same filter.  Well, it turns out that\r\n% multidimensional convolution of a 640-by-480-by-100 input with a \"flat\"\r\n% filter (that is, an M-by-N-by-1 filter) is exactly equivalent to filtering\r\n% each image in the sequence independently.\r\n%\r\n% For many users, though, this wasn't at all obvious, even if they did discover\r\n% the multidimensional capability of many of the functions.  So that's what led\r\n% to the \"Working with Sequences\" section in the doc.  But the multidimensional\r\n% functions can also handle volumetric processing, or other multidimensional\r\n% applications.  \r\n%\r\n% Still, multidimensional support remains somewhat \"hidden\" in the doc.  Here's\r\n% where you can almost always find it: Look in the \"Class Support\" section of a\r\n% function's reference page.  For example, here's what the Class Support section\r\n% for \r\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/images\/index.html \r\n% |watershed|> says:\r\n%\r\n% \"A can be a numeric or logical array of any dimension, and it must be\r\n% nonsparse.\"\r\n%\r\n% Whenever you see that \"of any dimension\" phrase, you'll know that the function\r\n% offers multidimensional support.\r\n%\r\n% PS.  Don't ask me to send you the code for |foobar|.  I lost it.\r\n##### SOURCE END ##### 511341e586e24afd97571929d8826b46\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Every so often someone asks in comp.soft-sys.matlab for a \"function like Image Processing Toolbox function foobar that works in 3-D.\"  If I happen to see the post, I will follow up, explaining... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2008\/03\/17\/multidimensional-image-processing\/\">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":[150],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/200"}],"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=200"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":2257,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/200\/revisions\/2257"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}