imglib / imglib2-roi

Regions of interest (ROIs) and labelings for ImgLib2
Other
8 stars 8 forks source link

OutOfBoundsStrategy for ROIs #6

Open dietzc opened 9 years ago

dietzc commented 9 years ago

Hi @tpietzsch,

would it make sense to offer a method in Regions which one can pass an IterableRegion, RandomAccessible<T> and an OutOfBoundsStrategy<T> and which returns a RandomAccessible<T> which returns the values of the passed RandomAccessible<T> on positions defined by the IterableRegion and values from the OutOfBoundsStrategy<T> on positions which lie outside the IterableRegion<T>?

tpietzsch commented 9 years ago

@dietzc I don't really understand the question. What would T be? The returned RandomAccessible<T> would have pixel values that are related to the IterableRegion how? I mean: assume I access position x in the returned RA. The source RA has value t, the (iterable) region is false at that position, what do I get?

dietzc commented 9 years ago

T can be arbitrary. You would get something defined by the OutOfBoundsStrategy<T>, which can be the t defined in the RandomAccessible<T> at the position you access (which is false for the (iterable) region) or something else (e.g. a constant value or some kind of mirroring). Of course one could achieve this by always checking if the (iterable) region I access is false or not at a given position and then return a constant value or the value of the RandomAccessible<T>. In the end the suggested method would just be a convenience method.

tpietzsch commented 9 years ago

@dietzc Ok, now I get it. Sounds like a good idea. Do you have any use-cases in mind?

tpietzsch commented 9 years ago

@dietzc Maybe I would name it differently though. We cannot use all of the existing OutOfBoundsStrategies, I think only Constant would make sense.

dietzc commented 9 years ago

ConstantValue is the only use-case I can currently think of. Mirror etc is tricky, because we of course of irregular shapes.