From 8d4aa443770db286d097e01a86c6ab08c974f653 Mon Sep 17 00:00:00 2001 From: Jan Brocher Date: Sun, 1 May 2022 17:57:13 +0200 Subject: [PATCH] add maxima sphere label splitting --- .../bv3dbox/gui/BV_PostProcessorGUI.java | 7 +++++-- .../gui/BV_VoronoiThresholdLabelingGUI.java | 7 +++++-- .../bv3dbox/plugins/BV_PostProcessor.java | 20 ++++++++++++++++++- .../plugins/BV_VoronoiThresholdLabeling.java | 10 +--------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_PostProcessorGUI.java b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_PostProcessorGUI.java index 360ee37..f72633a 100644 --- a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_PostProcessorGUI.java +++ b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_PostProcessorGUI.java @@ -14,6 +14,7 @@ import ij.WindowManager; import net.haesleinhuepf.clij.clearcl.ClearCLBuffer; import net.haesleinhuepf.clij2.CLIJ2; +import net.imagej.updater.UpdateService; /* * BSD 3-Clause License @@ -88,8 +89,8 @@ public void run() { private void setupImage() { - //BV3DBoxUtilities.displayMissingDependencyWarning(getContext().service(UpdateService.class), "clij,clij2"); - + BV3DBoxUtilities.displayMissingDependencyWarning(getContext().service(UpdateService.class), "clij,clij2,clijx-assistant,clijx-assistant-extensions,3D ImageJ Suite"); + bvpp = new BV_PostProcessor(inputImagePlus); outputImageName = "BVPP_" + inputImagePlus.getTitle(); @@ -123,6 +124,8 @@ public void processImage() { outputImagePlus.setTitle("BVPP_" + inputImagePlus.getTitle()); outputImagePlus.getProcessor().resetMinAndMax(); outputImagePlus.show(); + + BV3DBoxUtilities.adaptImageDisplay(inputImagePlus, outputImagePlus); } @SuppressWarnings("unused") diff --git a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_VoronoiThresholdLabelingGUI.java b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_VoronoiThresholdLabelingGUI.java index 0e6b5e7..6ff22c6 100644 --- a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_VoronoiThresholdLabelingGUI.java +++ b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/gui/BV_VoronoiThresholdLabelingGUI.java @@ -80,7 +80,7 @@ public class BV_VoronoiThresholdLabelingGUI extends DynamicCommand { @Parameter(label = "Threshold method", initializer = "thresholdMethodList", callback = "processImage") private String thresholdMethod = "Default"; - @Parameter(label = "Separation method", choices = {"None", "Maxima", "Eroded Maxima", "EDM Maxima", "DoG Seeds", "Eroded box", "Eroded sphere"}, callback = "processImage") + @Parameter(label = "Separation method", choices = {"None", "Maxima", "Eroded Maxima", "EDM Maxima", "Maxima Spheres", "DoG Seeds", "Eroded box", "Eroded sphere"}, callback = "processImage") private String separationMethod = "Maxima"; @Parameter(label = "Spot sigma / Erosion", min = "0f", callback = "processImage") @@ -137,7 +137,7 @@ public void run() { private void setupImage() { - BV3DBoxUtilities.displayMissingDependencyWarning(getContext().service(UpdateService.class), "clij,clij2"); + BV3DBoxUtilities.displayMissingDependencyWarning(getContext().service(UpdateService.class), "clij,clij2,clijx-assistant,clijx-assistant-extensions,3D ImageJ Suite"); bvvtl.setupInputImage(inputImagePlus); input_image = bvvtl.getInputImageAsClearClBuffer(); @@ -280,6 +280,9 @@ private void processImage() { case "EDM Maxima": seed_image = labelSplitter.detectDistanceMapMaxima(thresholded_image, maximaRadius); break; + case "Maxima Spheres": + seed_image = labelSplitter.createMaximaSpheres(thresholded_image, spotSigma, maximaRadius); + break; case "DoG Seeds": CLIJ2 clij2 = bvvtl.getCurrentCLIJ2Instance(); ClearCLBuffer binary_8_bit_image = clij2.create(thresholded_image); diff --git a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_PostProcessor.java b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_PostProcessor.java index 845c0a0..1bef10c 100644 --- a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_PostProcessor.java +++ b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_PostProcessor.java @@ -62,6 +62,7 @@ public class BV_PostProcessor extends DynamicCommand { private final PrefService prefs = new DefaultPrefService(); private static CLIJ2 clij2; private ClearCLBuffer input_image; + private BV_LabelSeparator bvls = new BV_LabelSeparator(); /** * @@ -136,7 +137,24 @@ public ClearCLBuffer postProcessor(String method, int iteration) { clij2.dilateLabels(temp_eroded, output_image, iteration); temp_eroded.close(); break; - + +// case "Close Label": +// ClearCLBuffer temp_dilated = clij2.create(input_image); +// +// clij2.dilateLabels(input_image, temp_dilated, iteration); +// +// ClearCLBuffer temp_splitted_labels = clij2.create(input_image); +// bvls.splitLabels(clij2, temp_dilated, temp_splitted_labels); +// temp_dilated.close(); +// +// if (is3D) { +// clij2.minimum3DSphere(temp_splitted_labels, output_image, iteration, iteration, iteration); +// } else { +// clij2.minimum2DSphere(temp_splitted_labels, output_image, iteration, iteration); +// } +// temp_splitted_labels.close(); +// break; + case "Minimum (sphere)": if (is3D) { clij2.minimum3DSphere(input_image, output_image, iteration, iteration, iteration); diff --git a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_VoronoiThresholdLabeling.java b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_VoronoiThresholdLabeling.java index e88b5b5..2f9d6ce 100644 --- a/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_VoronoiThresholdLabeling.java +++ b/BioVoxxel_3D_Box/src/main/java/de/biovoxxel/bv3dbox/plugins/BV_VoronoiThresholdLabeling.java @@ -391,7 +391,6 @@ public ClearCLBuffer thresholdImage(ClearCLBuffer background_subtracted_image, S - //TODO: Outlines does not work as intended, since the gray LUT is not applied to the output image public void createOutputImage(ClearCLBuffer output_image, String outputType) { ImagePlus tempOutputImagePlus = null; @@ -403,7 +402,7 @@ public void createOutputImage(ClearCLBuffer output_image, String outputType) { ClearCLBuffer temp_output_image = clij2.create(input_image); clij2.visualizeOutlinesOnOriginal(input_image, output_image, temp_output_image); - tempOutputImagePlus = BV3DBoxUtilities.pullImageFromGPU(clij2, temp_output_image, true, LutNames.GRAY); + tempOutputImagePlus = BV3DBoxUtilities.pullImageFromGPU(clij2, temp_output_image, true, LutNames.OUTLINE); temp_output_image.close(); } @@ -415,13 +414,6 @@ public void createOutputImage(ClearCLBuffer output_image, String outputType) { outputImagePlus.setImage(tempOutputImagePlus); outputImagePlus.setTitle(outputImageName); - - if (outputType.equals("Binary") || outputType.equals("Outlines")) { - outputImagePlus.setLut(grays); - } else { - outputImagePlus.setLut(glasbey); - } - outputImagePlus.show(); BV3DBoxUtilities.adaptImageDisplay(inputImagePlus, outputImagePlus);