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();
}
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;
}
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;
}
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();
}
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);
}
Aggregations