Search in sources :

Example 11 with Label

use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.

the class AddLabelingIoAction method addLabel.

// TODO: move to package Labeling
private void addLabel(Labeling labeling, Label label, IterableRegion<BitType> region) {
    String newLabelName = suggestName(label.name(), labeling.getLabels().stream().map(Label::name).collect(Collectors.toList()));
    if (newLabelName == null)
        return;
    Label newLabel = labeling.addLabel(newLabelName);
    Cursor<Void> cursor = region.cursor();
    RandomAccess<LabelingType<Label>> ra = labeling.randomAccess();
    while (cursor.hasNext()) {
        cursor.fwd();
        ra.setPosition(cursor);
        ra.get().add(newLabel);
    }
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label) LabelingType(net.imglib2.roi.labeling.LabelingType)

Example 12 with Label

use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.

the class ChangeLabel method actionPerformed.

@Override
public void actionPerformed(ActionEvent actionEvent) {
    List<Label> labels = model.labeling().get().getLabels();
    Label nextLabel = next(labels, model.selectedLabel().get());
    if (nextLabel != null)
        model.selectedLabel().set(nextLabel);
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label)

Example 13 with Label

use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.

the class ColoredLabelsModel method addLabel.

public void addLabel() {
    Holder<Labeling> holder = model.labeling();
    Labeling labeling = holder.get();
    String newName = suggestName(labeling.getLabels().stream().map(Label::name).collect(Collectors.toList()));
    if (newName == null)
        return;
    Label newLabel = labeling.addLabel(newName);
    model.selectedLabel().set(newLabel);
    fireLabelsChanged();
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Example 14 with Label

use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.

the class SelectLabelController method nextLabel.

private Optional<Label> nextLabel(LabelingType<Label> labels, Label label) {
    List<Label> visibleLabels = labels.stream().filter(Label::isVisible).collect(Collectors.toList());
    visibleLabels.sort(Comparator.comparing(model.labeling().get().getLabels()::indexOf));
    if (visibleLabels.contains(label)) {
        int index = visibleLabels.indexOf(label);
        return Optional.of(visibleLabels.get((index + 1) % visibleLabels.size()));
    }
    return visibleLabels.stream().findFirst();
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label) RealPoint(net.imglib2.RealPoint) Point(net.imglib2.Point)

Example 15 with Label

use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.

the class ImageLabelingModel method labelingReplacedEvent.

private void labelingReplacedEvent() {
    updateLabelTransform();
    Label selectedLabel = selectedLabelHolder.get();
    List<Label> labels = labelingHolder.get().getLabels();
    if (!labels.contains(selectedLabel))
        selectedLabelHolder.set(labels.isEmpty() ? null : labels.get(0));
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label)

Aggregations

Label (sc.fiji.labkit.ui.labeling.Label)15 Labeling (sc.fiji.labkit.ui.labeling.Labeling)6 LabelingType (net.imglib2.roi.labeling.LabelingType)5 BitType (net.imglib2.type.logic.BitType)5 Cursor (net.imglib2.Cursor)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Set (java.util.Set)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 ImgPlus (net.imagej.ImgPlus)2 Interval (net.imglib2.Interval)2 Point (net.imglib2.Point)2 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)2 RealPoint (net.imglib2.RealPoint)2 IterableRegion (net.imglib2.roi.IterableRegion)2 ARGBType (net.imglib2.type.numeric.ARGBType)2 Context (org.scijava.Context)2 FastRandomForest (hr.irb.fastRandomForest.FastRandomForest)1 File (java.io.File)1