imglib / imglib2-roi

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

Positionable Regions #51

Closed tpietzsch closed 4 years ago

tpietzsch commented 4 years ago

Adds a new Regions.positionable() static method that takes any RandomAccessibleInterval<BooleanType> and makes it an PositionableIterableRegion.

The PositionableIterableRegion is Positionable. It can be moved around, for example to Regions.sample() an image with the region positioned on different locations.

The PositionableIterableRegion has a PosionableLocalizable origin() that can be used to change the center of the region. The origin is the relative offset of the position to the minimum. For example if a positionable (bitmask) region is made from a BitType image with a circular pattern, then it is more natural if the region position refers to the center of the pattern instead of the upper left corner of the BitType image. This can be achieved by positioning the origin. Assume a region is created from a 9x9 bitmask. The region initially has min=(0,0), max=(8,8), position=(0,0). Because both position and min are (0,0), initially origin=(0,0). Now assume the origin is moved to the center of the bitmask using origin().setPosition(new int[]{4,4}). After this, min=(-4,-4), max=(4,4), position=(0,0), and origin=(4,4). region.setPosition() can now be used to put the center of the mask on some pixel. Then Regions.sample() can be used to overlay the region on a target image, and iterate the target pixels under the positioned region.

(This is part one of a framework that will allow to do Neighborhoods-like operations using arbitrary masks. Ultimately, the current Neighborhoods will be integrated into the same framework.)