Search in sources :

Example 21 with Labeling

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

the class AddLabelingIoAction method openAdditional.

private void openAdditional(Void ignore, String filename) throws IOException {
    Labeling newLabeling = serializer.open(filename);
    extendLabeling(labeling.get(), newLabeling);
    labeling.notifier().notifyListeners();
}
Also used : Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Example 22 with Labeling

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

the class InitialLabeling method askShrinkInterval.

private static Interval askShrinkInterval(Interval interval) {
    if (interval.numDimensions() != 2)
        return interval;
    if (!consideredBig(interval))
        return interval;
    interval = new FinalInterval(interval);
    List<Interval> suggestions = new ArrayList<>();
    suggestions.add(interval);
    while (consideredBig(interval)) {
        interval = shrink(interval);
        suggestions.add(interval);
    }
    List<String> texts = suggestions.stream().map(i -> i.dimension(0) + "x" + i.dimension(1)).collect(Collectors.toList());
    Object selected = JOptionPane.showInputDialog(null, "Select resultion of the labeling", "Labekit", JOptionPane.PLAIN_MESSAGE, null, texts.toArray(), texts.get(texts.size() - 1));
    int index = texts.indexOf(selected);
    return (index >= 0) ? suggestions.get(index) : interval;
}
Also used : IntStream(java.util.stream.IntStream) ImgPlus(net.imagej.ImgPlus) LongStream(java.util.stream.LongStream) OptionalDouble(java.util.OptionalDouble) Axes(net.imagej.axis.Axes) IOException(java.io.IOException) InputImage(sc.fiji.labkit.ui.inputimage.InputImage) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) Context(org.scijava.Context) File(java.io.File) ArrayList(java.util.ArrayList) NumericType(net.imglib2.type.numeric.NumericType) Intervals(net.imglib2.util.Intervals) List(java.util.List) Labeling(sc.fiji.labkit.ui.labeling.Labeling) DefaultLinearAxis(net.imagej.axis.DefaultLinearAxis) LabelingSerializer(sc.fiji.labkit.ui.labeling.LabelingSerializer) Interval(net.imglib2.Interval) FinalInterval(net.imglib2.FinalInterval) CalibratedAxis(net.imagej.axis.CalibratedAxis) ImgPlusViewsOld(sc.fiji.labkit.ui.inputimage.ImgPlusViewsOld) javax.swing(javax.swing) ArrayList(java.util.ArrayList) FinalInterval(net.imglib2.FinalInterval) Interval(net.imglib2.Interval) FinalInterval(net.imglib2.FinalInterval)

Example 23 with Labeling

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

the class InitialLabeling method defaultLabeling.

private static Labeling defaultLabeling(InputImage inputImage, List<String> defaultLabels) {
    ImgPlus<?> image = inputImage.imageForSegmentation();
    Interval bigInterval = new FinalInterval(ImgPlusViewsOld.hyperSlice(image, Axes.CHANNEL, 0));
    Interval smallInterval = askShrinkInterval(bigInterval);
    int scaling = getIntegerScale(smallInterval, bigInterval).getAsInt();
    Labeling labeling = Labeling.createEmpty(defaultLabels, smallInterval);
    labeling.setAxes(scaledAxes(scaling, filterChannelAxis(ImgPlusViewsOld.getCalibratedAxes(image))));
    return labeling;
}
Also used : FinalInterval(net.imglib2.FinalInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) Interval(net.imglib2.Interval) FinalInterval(net.imglib2.FinalInterval)

Example 24 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling 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 25 with Labeling

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

the class BitmapImportExportAction method exportLabel.

private void exportLabel(Label label, String filename) throws IOException {
    Labeling labeling = model.labeling().get();
    RandomAccessibleInterval<BitType> bitmap = labeling.getRegion(label);
    Dataset dataset = datasetService.create(toUnsignedByteType(bitmap));
    datasetIOService.save(dataset, filename);
}
Also used : BitType(net.imglib2.type.logic.BitType) Dataset(net.imagej.Dataset) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Aggregations

Labeling (sc.fiji.labkit.ui.labeling.Labeling)26 LabelingType (net.imglib2.roi.labeling.LabelingType)8 Label (sc.fiji.labkit.ui.labeling.Label)8 FinalInterval (net.imglib2.FinalInterval)7 BitType (net.imglib2.type.logic.BitType)7 Test (org.junit.Test)7 Context (org.scijava.Context)7 ImgPlus (net.imagej.ImgPlus)6 Interval (net.imglib2.Interval)6 Cursor (net.imglib2.Cursor)5 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)5 DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)5 File (java.io.File)4 List (java.util.List)4 Intervals (net.imglib2.util.Intervals)4 ValuePair (net.imglib2.util.ValuePair)4 Views (net.imglib2.view.Views)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3