Closed dietzc closed 8 years ago
another question, going in the same direction: The LabelRegionCursor
which implements Cursor<BoolType>
could (in theory) return Cursor<VoidType>
, as the returned BoolType
always true anyway (as we only iterate over the true pixels)?
If I understand it correctly, the BoolType
was just choosen, because there is nothing like a VoidType
and something has to be returned by the Cursor
? Again, I'm sure I'm missing something :-)
Why I'm asking all those questions: I'm currently trying to figure out how I would define a Polygon
and a Contour
interface which nicely fit into the imglib2-roi architecture. I need the Polygon
to describe the SmallestEnclosingRectangle
for example and the Contour
to describe e.g. the ConvexHull
of an object. My idea at the moment is: each Contour
is a Polygon
, with the property that all subsequent points are 4- or 8-connected. You can derive a Contour
from a Polygon
by interpolating between subsequent points of the Polygon
. However, I want also to be able to sample over them. In the case of a Polygon
over each pixel in the Polygon
and only over the contour-pixels in case of the Contour
. Therefore I was asking myself, which interfaces of imglib2-roi I could use to express these ideas. Maybe you have some advice, for example if I should work with Shape
or IterableRegion
?
Update: Replace the name of Contour
with Outline
if you want. This would be more Java-ish I think ;-)
see: https://github.com/imagej/imagej-ops/tree/geometricops/src/main/java/net/imagej/ops/geometric for some ideas. Maybe some of this work should rather be part of imglib2-roi. I would be happy to contribute, but I'm not sure if my implementations are going into the right direction.
@dietzc Actually, I think that having the ROI-related Iterables base on VoidType
is a very very very good idea. I feel a bit stupid for not thinking of it myself ;-)
I didn't actually try to put it into the existing code, but I'll make a branch and do that.
For now, I cannot foresee no real downsides of doing this.
And even if there are downsides, I think it is worth it: This will help to avoid confusion with calling Regions.iterable()
vs. Views.iterable()
on a BooleanType RAI, where Regions.iterable()
would only iterate the true
pixels while Views.iterable()
would iterate all pixels in the interval.
Now, a method like Regions.sample()
will simply require a IterableInterval<VoidType>
parameter, so if you used Views.iterable()
on a BooleanType RAI and passed it to sample
it simply won't compile.
@dietzc Regarding Polygon
and Contour
: To me both are defined in real coordinates. You said "My idea at the moment is: each Contour
is a Polygon
, with the property that all subsequent points are 4- or 8-connected." This suggests that somehow you mix in integer coordinates here. I would not do this for Polygon
or ConvexHull
.
Also: Contour
would be defined by tracing the border pixels of an (integer) connected region? Then it's not necessary convex? Anyway, this kind of Contour
would be an IterableRegion
to me, because the iteration order (tracing along the border) is the important information. The Polygon
would be RealRandomAccessible(Interval)<T extends BooleanType<T>>
. (You could get a discretized mask using Views.raster()
)
thanks for closing
Hi @tpietzsch,
is there a particular reason why
SamplingIterableInterval
has to be of typeBooleanType
? Because if we only sample on the targetRandomAccessible
, we don't really have to care about the functionality of theCursor
? We can actually sample over anyIterableInterval
, independent of the type, right?Probably I'm missing something.