imglib / imglib2-roi

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

Line iterable. #39

Closed tinevez closed 6 years ago

tinevez commented 6 years ago

An iterable over a quasi Bresenham line.

It will iterate exactly once over all the integer locations on a line between in proper order from the specified start to the specified end points, included.

This implementation uses floating-point logic instead of the pure integer logic of Bresenham line (Wikipedia) but the results are quasi identical and the performance penalty small.

awalter17 commented 6 years ago

Nicely done @tinevez! 😸

It may make sense to make this iterable quasi-Bresenham line its own class, and have it implement IterableInterval< Void >. That way you can use Regions.sample(...) to sample from a RandomAccessible along the line.

This may also make it easier to later fit this into the "ROI-schema" (i.e. make a line that is a MaskInterval, maybe an IterableRegion, etc.), once discrete ROIs have been worked out a bit more.

I'd also consider putting the "quasi-bresehamLineIterableInterval" class (I wouldn't actually name the class that) into a new package net.imglib2.roi.geom.integer.

tinevez commented 6 years ago

Working on it. Please don't merge. Also I will git push --force at some point.