Boost logo

Boost :

From: Paul Beardsley (pab_at_[hidden])
Date: 2001-09-26 11:53:35


Hi,

Someone told me that this group might accept questions
about designing an image class.

I am working on a computer vision library.
I am thinking of updating the existing image class design to
use Blitz++ to hold the image data. The primary reason for this
is to be able to handle expressions like the one below,
taking advantage of Blitz's ability to handle this without
creating temporaries,

  Image a, b, c, d;
  // ... initialize b, c, d ...
  a = b + c + d;

But I don't want to use the Blitz array class (or a Blitz-derived
class) directly in the code, for the following reason:
I don't want the template type (the pixel type) for the image
arrays to appear in the high-level software,
because it is irrelevant almost all the time, and adds
an unwanted templating into the code. I also want
to allow for easy dynamic changes to image type, for example
during a read from disk.

For this reason, I am thinking of a handle/body design
like the following.

  class MyImageHandle
  {
    ...
    MyImageBase* _base_ptr;
  };

  class MyImageBase
  {
    virtual void do () = 0;
  };

  template <typename T>
  class MyImage
    : public MyImageBase
  {
    void do ();
    BlitzArray<T> _blitz_array;
  }

Then be able to do things like,

  MyImageHandle a, b, c, d;
  // ... initialize b, c, d
  a = b + c + d;

so that behind the scenes, the image handles cause
a dynamic cast of their _base_ptrs to get the actual templated
images, and an
efficient addition occurs using the Blitz arrays.

I did not yet think through all the "behind the scenes"
part but it seems it would not be trivial, and I don't
want to have temporaries appearing. Are there
any existing image/array classes which have addressed
this problem? Or does anyone have suggestions or advice?

Thanks,
Paul.

(p.s. I already mailed the blitz-support mailing list.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk