Closed imagejan closed 4 years ago
- Is there any interest to have this as a static method in
net.imglib2.roi.labeling.Labelings
?
It would be cool to have this, absolutely!
- Is this any better than simply creating a new labeling and iterating over input and output with two
Cursor
s?
It would be definitely much faster.
The only potential problem is if function
is not injective. I'm not sure what would happen if you have function = {1->a, 2->a, 3->b, ... } and now the previously distinct label sets {1}, {2}, and {1,2} all become {a}. But if it is a problem, we could just point out in the javadoc that is is not allowed.
I was considering adding a utility method to transform
ImgLabeling
s by mapping the existing labelsT
to some new labelsU
, given aFunction<T,U>
.This would be similar to what the Label Transformer node in
knime-ip/knip
is currently doing.Two questions:
net.imglib2.roi.labeling.Labelings
?LabelingMapping<T>
from the input, transforming its labelsSet<T>
to new sets of labelsSet<U>
with the given function, and then creating a newImgLabeling<U> result
with the same index image, and setting the labels withresult.getMapping().setLabelSets(newLabelSets)
. Is this any better than simply creating a new labeling and iterating over input and output with twoCursor
s?