Open tpietzsch opened 5 years ago
@tpietzsch I made some quick changes.
@maarzt I fixed the bug. Thanks for noticing!
Bitmask is probably not a got term to refer to a black/white image. Mask or Bitmap are preferable. Bitmask is rather one dimensional. https://en.wikipedia.org/wiki/Bitmap https://en.wikipedia.org/wiki/Mask
This pull request has been mentioned on Image.sc Forum. There might be relevant details there:
SparseBitmask
is aRandomAccessible<BoolType>
based on nTree (quadtree, octree, ...) with little bitmasks (basicallyArrayImg<BitType>
) in the leafs. It's aRandomAccessible
(notInterval
). The tree grows on demand, just set pixels wherever...There are efficient algorithms for
true
) pixels,true
) pixels.These are provided through a (read-only) view as an
IterableRegion
.Some usage examples are in src/test/.
I'm happy with the underlying tree and bitmask stuff (
SparseBitmaskNTree
,Tree
,GrowableTree
). However, packaging as aRandomAccessible
inSparseBitmask
required some trade-offs that are not so clear and depend on use case. I would be happy about some input...In particular, read/write of pixels is protected by a
ReentrantReadWriteLock
that is acquired per pixel access. It would be nice to have this more coarse-grained, but I don't know how.Also,
SparseBitmask.region()
providesIterableRegion
view of the current state, and will throwConcurrentModificationException
when the bitmask is modified. There are some minor trade-offs there as well, but read/write locking is the major problem.