Search in sources :

Example 6 with Label

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

the class ColoredLabelsModel method moveLabel.

public void moveLabel(Label label, int movement) {
    Labeling labeling = model.labeling().get();
    List<Label> oldOrder = new ArrayList<>(labeling.getLabels());
    Function<Label, Double> priority = l -> oldOrder.indexOf(l) + (l == label ? movement + 0.5 * Math.signum(movement) : 0.0);
    labeling.setLabelOrder(Comparator.comparing(priority));
    fireLabelsChanged();
}
Also used : BitType(net.imglib2.type.logic.BitType) Notifier(sc.fiji.labkit.ui.utils.Notifier) IterableRegion(net.imglib2.roi.IterableRegion) ARGBType(net.imglib2.type.numeric.ARGBType) LabelPanel(sc.fiji.labkit.ui.panel.LabelPanel) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) Cursor(net.imglib2.Cursor) Labeling(sc.fiji.labkit.ui.labeling.Labeling) Interval(net.imglib2.Interval) FinalInterval(net.imglib2.FinalInterval) Label(sc.fiji.labkit.ui.labeling.Label) Comparator(java.util.Comparator) Label(sc.fiji.labkit.ui.labeling.Label) ArrayList(java.util.ArrayList) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Example 7 with Label

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

the class BrushCursor method drawOverlays.

@Override
public void drawOverlays(final Graphics g) {
    if (visible) {
        final Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setComposite(AlphaComposite.SrcOver);
        Label label = model.selectedLabel().get();
        if (label != null) {
            Color color = new Color(label.color().get());
            String title = label.name();
            if (fontVisible)
                drawTitle(g2d, color, title);
            drawCircle(g2d, color);
        }
    }
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label)

Example 8 with Label

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

the class LabelBrushController method makeLabelVisible.

private void makeLabelVisible() {
    Label label = model.selectedLabel().get();
    if (label == null)
        return;
    if (label.isVisible() && model.labelingVisibility().get())
        return;
    label.setVisible(true);
    model.labelingVisibility().set(true);
    model.labeling().notifier().notifyListeners();
}
Also used : Label(sc.fiji.labkit.ui.labeling.Label)

Example 9 with Label

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

the class SelectLabelController method click.

private void click(int x, int y) {
    RealPoint globalPosition = new RealPoint(3);
    viewer.displayToGlobalCoordinates(x, y, globalPosition);
    model.labelTransformation().applyInverse(globalPosition, globalPosition);
    globalPosition.move(PIXEL_CENTER_OFFSET);
    RandomAccess<LabelingType<Label>> ra = labeling().randomAccess();
    ra.setPosition(roundAndReduceDimension(globalPosition, ra.numDimensions()));
    Optional<Label> label = nextLabel(ra.get(), model.selectedLabel().get());
    label.ifPresent(model.selectedLabel()::set);
}
Also used : RealPoint(net.imglib2.RealPoint) Label(sc.fiji.labkit.ui.labeling.Label) LabelingType(net.imglib2.roi.labeling.LabelingType)

Example 10 with Label

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

the class FloodFillTest method test3.

@Test
public void test3() {
    Labeling labeling = Labeling.fromImgLabeling(exampleImgLabeling());
    final Point seed = new Point(2, 2);
    Label a = labeling.getLabel("a");
    Label b = labeling.getLabel("b");
    Label c = labeling.getLabel("c");
    c.setVisible(false);
    Label ab = labeling.addLabel("ab");
    final Consumer<Set<Label>> operation = l -> l.add(ab);
    FloodFill.doFloodFillOnActiveLabels((RandomAccessibleInterval) labeling, seed, operation);
    assertLabelEqualsInterval(labeling, intervalA, a);
    assertLabelEqualsInterval(labeling, intervalB, b);
    assertLabelEqualsInterval(labeling, intervalC, c);
    assertLabelEqualsInterval(labeling, intervalAintersectB, ab);
}
Also used : BitType(net.imglib2.type.logic.BitType) Point(net.imglib2.Point) Predicate(java.util.function.Predicate) Set(java.util.Set) Test(org.junit.Test) Consumer(java.util.function.Consumer) Intervals(net.imglib2.util.Intervals) Cursor(net.imglib2.Cursor) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabelingType(net.imglib2.roi.labeling.LabelingType) ArrayImgs(net.imglib2.img.array.ArrayImgs) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Interval(net.imglib2.Interval) Label(sc.fiji.labkit.ui.labeling.Label) Views(net.imglib2.view.Views) Assert.assertEquals(org.junit.Assert.assertEquals) Set(java.util.Set) Label(sc.fiji.labkit.ui.labeling.Label) Point(net.imglib2.Point) Labeling(sc.fiji.labkit.ui.labeling.Labeling) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Test(org.junit.Test)

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