Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Steve on Image Processing

March 17th, 2008

Multidimensional Image Processing

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 that foobar itself works just fine in 3-D.

So in case some blog readers have been looking for a "3-D version of foobar," I thought I'd mention it here.

In the late 1990s we started hearing about requests for three-dimensional image processing support. Then on some customer visits in 2000 we heard some demand for four-dimensional support! As a result, the major Image Processing Toolbox upgrade in 2001 (version 3.0) added arbitrary dimension support to the toolbox.

Many Image Processing Toolbox functions implement mathematical operations (such as convolution) that are perfectly well defined in multidimensional spaces. So our strategy was to go ahead and implement multidimensional support for all such functions.

The meaning of the higher dimensions varies with the application and the data. With volumetric data (pixels become "voxels"), the 3rd dimension is spatial, just like the first two. Sometimes a higher dimension is time, or sequence number. And sometimes a higher dimension is spectral, as in color images or multispectral imagery.

At some point after 2001, we began to realize that users weren't discovering the multidimensional capability of the toolbox. Our first attempt to rectify that problem came when we added documentation sections explaining how to use toolbox functions 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 in higher dimensions often just do "the right thing" when you have an image sequence represented in MATLAB as a three-dimensional array.

Let me explain that statement. Suppose you have a 640-by-480-by-100 array, representing 100 images in a sequence. And suppose you want to filter each image in the sequence with the same filter. Well, it turns out that multidimensional convolution 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 image in the sequence independently.

For many users, though, this wasn't at all obvious, even if they did discover the multidimensional capability of many of the functions. So that's what led to the "Working with Sequences" section in the doc. But the multidimensional functions can also handle volumetric processing, or other multidimensional applications.

Still, multidimensional support remains somewhat "hidden" in the doc. Here's where you can almost always find it: Look in the "Class Support" section of a function's reference page. For example, here's what the Class Support section for watershed says:

"A can be a numeric or logical array of any dimension, and it must be nonsparse."

Whenever you see that "of any dimension" phrase, you'll know that the function offers multidimensional support.

PS. Don't ask me to send you the code for foobar. I lost it.


Get the MATLAB code

Published with MATLAB® 7.6

7 Responses to “Multidimensional Image Processing”

  1. David Schoppik replied on :

    Good post. It is worth mentioning that many of the operations that “just work” in 3D actually depend on passing things in the appropriate orientation. Further, it can be fairly difficult to troubleshoot whether the output of “foobar” (or, say, fft) when passed a multidimensional array is actually what you wanted — unless you’re lucky enough that all you want to do is smooth/filter each frame of a movie, and you know what a smoothed frame ought to look like.
    I believe the problem is not so much the fact that multidimensional support remains hidden, but rather that it is fairly difficult to think about things in 4D, particularly when what you’d like to happen to your data isn’t entirely obvious.

  2. Steve replied on :

    David—Thanks for your observations.

  3. Shalin replied on :

    Thanks for the post, Steve. I would like to use MATLAB’s deconvblind for 3D deconvoluton of microscopy datasets and had been wondering how to do it. I have few specific questions: a) Could the initial PSF be 3D or of dimension same as image dimension? The help mentions that image can be N-dimensional and what can be data types of image and PSF.

    b) Since the size and shape of PSF are more important then the actual values contained in it, will specifying particular shape as a pattern of 1’s work. e.g. in microscopy the PSFs look like hour-glass or egg-shaped for widefield and confocal imaging, respectively. If I were to represent 3D hour-glass or egg-shape as consisting of 1’s in a cube of zeros, should it work?

  4. Steve replied on :

    Shalin—Yes, the PSF can be three-dimensional in deconvblind. I think it would be fine to start with a pattern of 1s as the initial estimate.

  5. Mark Hayworth replied on :

    Steve:
    When will bwmorph be generalized to 3D? Currently it says “The input image BW can be numeric or logical. It must be 2-D, real and nonsparse.” I have an x-ray CT volume image of a bottle that I would like to thin down to a single sheet using the ’skel’ option of bwmorph. (Normally the bottle wall is thick, like a slab, with a thickness of several voxels and I want just a single voxel thickness). Any workarounds until we get a 3D version of bwmorph? imerode says it works in 3D but it apparently doesn’t have an option to not break apart structures so some parts of the slab could erode away to zero while others would still have a thickness, if the thickness varied from point to point. (BTW Likewise, imdilate apparently lacks a method to prevent two separate blobs from joining - bummer.)

  6. Steve replied on :

    Mark—I don’t know. It won’t happen for R2008b. imdilate and imerode do work in three (or higher) dimensions, but they implement dilation and erosion, which are different from the 2-D ‘thicken’ and ‘thin’ operations offered by bwmorph.

  7. Steve replied on :

    Mark—There is a 3-D skeletonization routine available on the MATLAB Central File Exchange you could try. But now I see from the reviews of that submission that you already found it. I would be very interested to know if the method works for your problem.

Leave a Reply


Steve Eddins manages the Image & Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.

  • ismail: i love chess keep posting :) can we make a web cam identify a chess set ? so we have a roboarm plays for real...
  • Navan: While black is going to win with a smothered mate, it is hard to see what moves would have led to this...
  • Doug: Forced ’smothermate&# 8217; is about to happen, with the added insult of threatening the queen on the...
  • Viton: Let’s give it a try: - RxQ : White Rook takes black Queen (White King was checked, can’t take...
  • Omar: Hi Steve, when using tformfwd to find corresponding points in the new space, the resulting co-ordinates from...
  • Steve: Cris—You’ ;re right, I should have caught the plot scaling issue. I wasn’t actually trying...
  • Cris Luengo: Not to spoil your upcoming bog entry too much, but if you scale the first graph (times vs Q) by setting...
  • Steve: Jim—Thanks for adding your comment showing how the syntax works for matrices.
  • Jim: for i = A …statements 230; end; Description: The …statements 230; are executed (as MATLAB...
  • Steve: Omar—Nice work.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.

Related Topics