imglib / imglib2

A generic next-generation Java library for image processing
http://imglib2.net/
Other
302 stars 91 forks source link

Iterables and RealIterables for non-Intervals #13

Open ctrueden opened 11 years ago

ctrueden commented 11 years ago

It would be nice to be able to have an object which is Iterable but not necessarily an Interval or RealInterval. So far we have been using Java's Iterable class, but we want to extend it to support the cursor() method to return a Cursor (in the case of Iterable) or RealCursor (in the case of RealIterable).

The original thinking for not having a non-Interval Iterable was that there are always a finite number of elements in the iteration and hence ultimately there are min and max bounds for the Interval from those. But that is questionable: Java's Iterable actually does not enforce there being a limit to the iteration (i.e., there is no size() method). Of course, Java's Iterable was intended for use with the Collections framework, and all Collections have an int size(), but ImgLib2 does not use Collection directly. (Some types define a size() but it is typically a long, for example.) Of course, if your Iterable isn't actually finite, there are other serious problems: a naive iteration loop over all elements will never terminate—in practice, ImgLib2 has an implicit assumption that all Iterables have a finite number of elements.

acardona commented 11 years ago

2013/4/30 Curtis Rueden notifications@github.com

It would be nice to be able to have an object which is Iterable but not necessarily an Interval or RealInterval. So far we have been using Java's Iterable class, but we want to extend it to support the cursor() method to return a Cursor (in the case of Iterable) or RealCursor (in the case of RealIterable).

The original thinking for not having a non-Interval Iterable was that there are always a finite number of elements in the iteration and hence ultimately there are min and max bounds for the Interval from those. But that is questionable: Java's Iterable actually does not enforce there being a limit to the iteration (i.e., there is no size() method). Of course, Java's Iterable was intended for use with the Collections framework, and all Collections have an int size(), but ImgLib2 does not use Collection directly. (Some types define a size() but it is typically a long, for example.) Of course, if your Iterable isn't actually finite, there are other serious problems: a naive iteration loop over all elements will never terminate—in practice, ImgLib2 has an implicit assumption that all Iterables have a finite number of elements.

I'd say instead that, if anything, a view on an iterable has a limited number of elements (and not even views may be limited). An iterable per se may be a function that can generate values for any field of view, like Mandelbrot's fractal.

Albert

http://albert.rierol.net http://www.ini.uzh.ch/~acardona/

axtimwalde commented 11 years ago

Do you have a specific application in mind?

tpietzsch commented 11 years ago

Phyllotaxis samples from a fractal? :-D