Skip to content

Commit

Permalink
- Fix for the SlopeOverlapResolver (by Mark Hiner)
Browse files Browse the repository at this point in the history
- Saves the settings now
- Release 1.1.2
  • Loading branch information
jumpfunky committed Nov 11, 2015
1 parent 27c0282 commit 5a78f99
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 25 deletions.
88 changes: 76 additions & 12 deletions src/main/java/de/biomedical_imaging/ij/steger/Lines_.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import ij.IJ;
import ij.ImagePlus;
import ij.Prefs;
import ij.gui.DialogListener;
import ij.gui.GenericDialog;
import ij.gui.Overlay;
Expand All @@ -58,26 +59,47 @@ public class Lines_ implements ExtendedPlugInFilter, DialogListener {
double contrastLow = contrastLowDefault;

final static double sigmaDefault = 1.51;
double sigma = 1.5;
double sigma = sigmaDefault;

final static double lowerThreshDefault = 3.06;
double lowerThresh = lowerThreshDefault;

final static double upperThreshDefault = 7.99;
double upperThresh = upperThreshDefault;
boolean isDarkLine = false;
boolean doCorrectPosition = false;
boolean doEstimateWidth = false;
boolean doExtendLine = true;
boolean showJunctionPoints = false;
boolean isPreview = false;
boolean displayResults = true;
boolean addToRoiManager = true;

final static boolean isDarkLineDefault = false;
boolean isDarkLine = isDarkLineDefault;

final static boolean doCorrectPositionDefault = false;
boolean doCorrectPosition = doCorrectPositionDefault;

final static boolean doEstimateWidthDefault = false;
boolean doEstimateWidth = doEstimateWidthDefault;

final static boolean doExtendLineDefault = true;
boolean doExtendLine = doExtendLineDefault;

final static boolean showJunctionPointsDefault = false;
boolean showJunctionPoints = showJunctionPointsDefault;

final static boolean displayResultsDefault = true;
boolean displayResults = displayResultsDefault;

final static boolean addToRoiManagerDefault = true;
boolean addToRoiManager = addToRoiManagerDefault;

OverlapOption overlapOption = OverlapOption.NONE;

final static boolean showIDsDefault = false;
boolean showIDs = showIDsDefault;

final static boolean verboseDefault = false;
boolean verbose = verboseDefault;

boolean isPreview = false;
boolean contrastOrLineWidthChangedOnce = false;
boolean doStack = false;
boolean showIDs = false;
boolean verbose = false;

private Options usedOptions = null;
private static Lines_ instance = null;

Expand Down Expand Up @@ -148,7 +170,7 @@ public int setup(String arg, ImagePlus imp) {
this.imp = imp;
result = new ArrayList<Lines>();
resultJunction = new ArrayList<Junctions>();

readSettings();
return DOES_8G + DOES_STACKS + FINAL_PROCESSING + PARALLELIZE_STACKS;
}

Expand Down Expand Up @@ -235,16 +257,58 @@ public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
displayResults = gd.getNextBoolean();
addToRoiManager = gd.getNextBoolean();
overlapOption = OverlapOption.valueOf(gd.getNextChoice());
saveSettings();

result = new ArrayList<Lines>();
resultJunction = new ArrayList<Junctions>();

int labels = IJ.setupDialog(imp, DOES_8G + FINAL_PROCESSING
+ PARALLELIZE_STACKS);
doStack = (labels!=DOES_8G + FINAL_PROCESSING
+ PARALLELIZE_STACKS);

return labels;
}

private void readSettings(){
lineWidth = Prefs.get("RidgeDetection.lineWidth", lineWidthDefault);
contrastHigh = Prefs.get("RidgeDetection.contrastHigh", contrastHighDefault);
contrastLow = Prefs.get("RidgeDetection.contrastLow", contrastLowDefault);
sigma = Prefs.get("RidgeDetection.sigma",sigmaDefault);
lowerThresh = Prefs.get("RidgeDetection.lowerThresh", lowerThreshDefault);
upperThresh = Prefs.get("RidgeDetection.upperThresh", upperThreshDefault);
isDarkLine = Prefs.get("RidgeDetection.isDarkLine", isDarkLineDefault);
doCorrectPosition = Prefs.get("RidgeDetection.doCorrectPosition", doCorrectPositionDefault);
doEstimateWidth = Prefs.get("RidgeDetection.doEstimateWidth", doEstimateWidthDefault);
doExtendLine = Prefs.get("RidgeDetection.doExtendLine", doExtendLineDefault);
showJunctionPoints = Prefs.get("RidgeDetection.showJunctionPoints", showJunctionPointsDefault);
showIDs = Prefs.get("RidgeDetection.showIDs", showIDsDefault);
verbose = Prefs.get("RidgeDetection.verbose", verboseDefault);
displayResults = Prefs.get("RidgeDetection.displayResults", displayResultsDefault);
addToRoiManager = Prefs.get("RidgeDetection.addToRoiManager", addToRoiManagerDefault);
String overlapOptionString = Prefs.get("RidgeDetection.overlapOption", OverlapOption.NONE.name());
overlapOption = OverlapOption.valueOf(overlapOptionString);
}

private void saveSettings(){
Prefs.set("RidgeDetection.lineWidth", lineWidth);
Prefs.set("RidgeDetection.contrastHigh", contrastHigh);
Prefs.set("RidgeDetection.contrastLow", contrastLow);
Prefs.set("RidgeDetection.sigma", sigma);
Prefs.set("RidgeDetection.lowerThresh", lowerThresh);
Prefs.set("RidgeDetection.upperThresh", upperThresh);
Prefs.set("RidgeDetection.isDarkLine", isDarkLine);
Prefs.set("RidgeDetection.doCorrectPosition", doCorrectPosition);
Prefs.set("RidgeDetection.doEstimateWidth", doEstimateWidth);
Prefs.set("RidgeDetection.doExtendLine", doExtendLine);
Prefs.set("RidgeDetection.showJunctionPoints", showJunctionPoints);
Prefs.set("RidgeDetection.showIDs", showIDs);
Prefs.set("RidgeDetection.verbose", verbose);
Prefs.set("RidgeDetection.displayResults", displayResults);
Prefs.set("RidgeDetection.addToRoiManager", addToRoiManager);
Prefs.set("RidgeDetection.overlapOption", overlapOption.name());
}

public void addToRoiManager(){
RoiManager rm = RoiManager.getInstance();
if(rm==null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import ij.IJ;

import java.awt.Checkbox;
import java.awt.Choice;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -62,6 +64,18 @@ public void actionPerformed(ActionEvent arg0) {
textUppThresh.setText("" + IJ.d2s(Lines_.upperThreshDefault, 2));
textUppThresh.setEditable(true);

((Checkbox)gd.getCheckboxes().get(0)).setState(Lines_.isDarkLineDefault);
((Checkbox)gd.getCheckboxes().get(1)).setState(Lines_.doCorrectPositionDefault);
((Checkbox)gd.getCheckboxes().get(2)).setState(Lines_.doEstimateWidthDefault);
((Checkbox)gd.getCheckboxes().get(3)).setState(Lines_.doExtendLineDefault);
((Checkbox)gd.getCheckboxes().get(4)).setState(Lines_.showJunctionPointsDefault);
((Checkbox)gd.getCheckboxes().get(5)).setState(Lines_.showIDsDefault);
((Checkbox)gd.getCheckboxes().get(6)).setState(Lines_.verboseDefault);
((Checkbox)gd.getCheckboxes().get(7)).setState(Lines_.displayResultsDefault);
((Checkbox)gd.getCheckboxes().get(8)).setState(Lines_.addToRoiManagerDefault);

((Choice)gd.getChoices().get(0)).select(0);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,36 @@ private void findOverlap(final Set<Line> enclosed,

// clean up enclosed lines.. any enclosed line that intersects with another
// enclosed line at BOTH ends should be removed.
final Set<Line> toRemove = new HashSet<Line>();

for (final Line l1 : enclosed) {
boolean foundStartMatch = false;
boolean foundEndMatch = false;
boolean pruneEnclosed = true;

for (final Line l2 : enclosed) {
if (l2 == l1) continue;
else if (intersectsStart(l1, l2, SIGMA)) foundStartMatch = true;
else if (intersectsEnd(l1, l2, SIGMA)) foundEndMatch = true;
while (pruneEnclosed) {
pruneEnclosed = false;
Line toRemove = null;

for (final Line l1 : enclosed) {
boolean foundStartMatch = false;
boolean foundEndMatch = false;

for (final Line l2 : enclosed) {
if (l2 == l1) continue;
else if (intersectsStart(l1, l2, SIGMA)) foundStartMatch = true;
else if (intersectsEnd(l1, l2, SIGMA)) foundEndMatch = true;

if (foundStartMatch && foundEndMatch) break;
}

// found a line to prune
// remove it and restart
if (foundStartMatch && foundEndMatch) {
toRemove = l1;
pruneEnclosed = true;
}
}

if (foundStartMatch && foundEndMatch) toRemove.add(l1);
if (toRemove != null) enclosed.remove(toRemove);
}

for (final Line l : toRemove)
enclosed.remove(l);

if (verbose) {
for (final Line l : enclosed)
IJ.log("Found enclosed line: " + l.getID());
Expand Down Expand Up @@ -648,4 +660,4 @@ private boolean matchesEnd(final Junction junction, final Line line) {
return line.getXCoordinates()[count] == junction.getX() && line
.getYCoordinates()[count] == junction.getY();
}
}
}

0 comments on commit 5a78f99

Please sign in to comment.