Steve on Image Processing

August 18th, 2009

Moving toolbox functions into MATLAB

I'm sorry to have disappeared off the blogging map the last couple of weeks. I got involved in some projects that needed many hours of uninterrupted, focused time, which somehow doesn't mesh well with keeping up with the blog. ;-)

Last week StephenLL commented on my "Five years of Image Processing Toolbox changes" post. Stephen said he'd like to see the function padarray moved into MATLAB.

I think that's a reasonable request.

There have been several cases in the past when we have moved Image Processing Toolbox functionality into MATLAB.

The first case was the image file reading and writing functions. When Image Processing Toolbox version 1.0 shipped in 1993, it included several pairs of functions for reading and writing image formats: tiffread, tiffwrite, bmpread, bmpwrite, etc. Pretty soon, users started complaining that we were charging them for a toolbox when all they wanted to do was read or write a TIFF file. So we decided to move the functionality into MATLAB. Based on our experience with the original functions, we also decided to present the functionality with redesigned interfaces. For example, we learned that it was frequently useful to be able to read the metadata from an image file without actually reading the image pixels. The new image I/O functions were imread, imwrite, and imfinfo, and they shipped with MATLAB 5.0 in 1997.

A simpler MATLAB move, similar to what Stephen is suggesting for padarray, happened a little bit later with circshift. This is one of the earliest cases I can remember where an Image Processing Toolbox function moved without modification into MATLAB. In this case, the first opportunity to ship the function was in a toolbox release, but it was written with the idea that it might go into MATLAB at some point.

The Image Processing Toolbox function ind2rgb moved into MATLAB a year or two after MATLAB 5.0. The driving factor here was the newly added ability to put image data onto user interface buttons in Handle Graphics. Users would read an indexed image from an indexed image file, for example, but then get stuck because the button wouldn't take the image data in indexed form.

The function rgb2ind eventually found its way from the toolbox into MATLAB also, but not until the R2009a release earlier this year. This change was motivated in part by the reintroduction of GIF format support a couple of years ago. Users wanted to write GIF files, but the GIF format supports only indexed images, and MATLAB users without the Image Processing Toolbox found it difficult to convert their truecolor images to indexed form.

Moving rgb2ind was actually a fairly complicated move. Conversion to indexed format is a complex calculation, and rgb2ind called several other Image Processing Toolbox functions to do portions of the work. So all of these functions moved over to MATLAB together with rgb2ind.

I wrote the original version of padarray and figured it might be a candidate for moving into MATLAB at some point. I can't really say for sure, though, whether and when that might happen. Such a function move affects product tests, reference pages, release notes, and so it requires coordination from several people and maybe a day or two of person-time. I suspect also that the current implementation may have some dependencies on other Image Processing Toolbox utility functions, so these dependencies would need to be resolved. It's not a huge amount of time, but then we never seem to have enough time to do everything we want to do with the product.

Anyway, thanks again, Stephen, for the suggestion.


Get the MATLAB code

Published with MATLAB® 7.8

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


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.

  • Sana: hi steve, could you explain to me how i would be able to use the dir function, to do a loop through a directory...
  • Nishtha: Sir, I have preprocessed the image in following steps: [1] adaptive histogram equalization [2] thresholding...
  • Kristof: I also strongly support the idea. I have just recently bumped into the problem that im2single was not...
  • Steve: David—I’ m glad you found it useful!
  • David Lalejini: I found your example very useful for finding connected nodes in a large set of input pairs. I start...
  • tommy: Dear Steve, I have a question,please if you are kind to help me regarding the accumulator array dimensions of...
  • Steve: Abc—I don’t know how to distinguish the faces. You might try posting your question in the MATLAB...
  • Manju: well if we have a few ovals within each other like in a cell how do we measure the distance from the center...
  • Steve: Manju—What do you mean? How is each region defined?
  • Manju: if we have 2-3 regions within each other how do we measure the regions of each one?

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