Boost logo

Boost :

From: Ullrich Koethe (u.koethe_at_[hidden])
Date: 2001-11-15 14:04:57


Peter Dimov wrote:
>
> From: "Ullrich Koethe" <u.koethe_at_[hidden]>
> > Peter Dimov wrote:
> > > The interface as presented to the user would be orthogonal:
> > >
> > > basic_image<bool, linear> // == basic_image<unsigned char, linear>
> > > basic_image<bool, packed> // == vector<bool>
> > > basic_image<bool, rle>
> > > basic_image<unsigned char, linear>
> > > basic_image<unsigned char, rle>
> >
> > So you would specialize algorithms on storage format (linear, packed,
> > rle)? Interesting, but a lot of work (some algorithms are needed 3
> > times).
>
> Only where it makes sense.
>
> Look at it this way. The choices are:
>
> [1]
>
> basic_image<T> - linear
> packed_image // always bool
> rle_image // always bool
>
> [2]
>
> basic_image<T>
> basic_image<packed_bool>
> basic_image<rle_bool>
>
> or [3] - see above.
>
> The difference is that in [3] you may choose what to specialize and what to
> leave to the generic version to handle.
>

Since I'm using iterators, I'll have to specialize on iterator type. So,
iterator traits must contain the storage formats of the corresponding
container. Looks workable.

> > No, I also have accessors for variable band formats (SequenceAccessor,
> > VectorAccessor and VectorBandAccessor)
>
> True, but having
>
> image<std::vector<unsigned char> >
>
> would be quite inefficient since the vectors won't exploit the fact that
> they are the same size. Or am I missing something.
>

Yes, because the accessors only require a vector _interface_. So you can
define a

vector_image<unsigned char>

that allocates a contigous block of memory, and considers stretches of n
values as one pixel. The iterator would then return an appropriate proxy
that implements the required interface on top of this. (Which brings me
to proxies, who would warrant a discussion of their own...)

Ulli

-- 
 ________________________________________________________________
|                                                                |
| Ullrich Koethe  Universität Hamburg / University of Hamburg    |
|                 FB Informatik / Dept. of Computer Science      |
|                 AB Kognitive Systeme / Cognitive Systems Group |
|                                                                |
| Phone: +49 (0)40 42883-2573                Vogt-Koelln-Str. 30 |
| Fax:   +49 (0)40 42883-2572                D - 22527 Hamburg   |
| Email: u.koethe_at_[hidden]               Germany             |
|        koethe_at_[hidden]                        |
| WWW:   http://kogs-www.informatik.uni-hamburg.de/~koethe/      |
|________________________________________________________________|

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