
Hi Luis On Wed, Oct 17, 2012 at 7:47 AM, Luis Pedro Coelho <luis@luispedro.org> wrote:
I don't however, do all combinations. For example
erode(image, structuring_element)
will convert structuring_element to the type of image. This way only one instance for type is generated (also, structuring_element is guaranteed to be PyArray_CARRAY). structuring_element is often really small, so the time cost is negligable.
I think that is some very sensible and pragmatic advice; thank you!
My initial variants did generate all combinations and it rapidly became very large (a few MB for morphological functions, for example).
OK, so we definitely have to be careful.
PS: support for multiple types without a performance cost was one of the original reasons why I rejected Cython in favour of C++ (the other was that, when I started mahotas, Cython was still Pyrex and still a major pain for users to install).
That was probably a good choice; we made a design decision to almost always operate on floating point images internally, but that comes with its own pros and cons (e.g., memory use with very large images). On the other hand, it also means that a lot of the overhead previous devoted to thinking about ranges can now be dropped (I find it a lot simpler to code up an algorithm, knowing I'm dealing with values in [0, 1]). Cheers Stéfan