public class InteractiveSnake extends ImageReviewer implements ij.plugin.PlugIn
bugs and fixes:
WO 5/1/2012 I am able to adjust other points, but at times when adjusting an end-point,
find_opt takes for solution a point very far away. I believe I isolated the error to the enforcing the point
to not be too far outside. The inward normal is computed correctly. When a point is deemed too far outside,
it dictates a location along the normal 2 cm past the last edge point, and this is way off in this case.
WO 6/1/2012 after adjusting endpoint, find_opt then moves that end point~ 5 pixels toward its original set location.
Sometimes the final point is not near any edge either, and not near the location selected.
-soln: recomputeSnake calls resampleSnake which uses the smoothsnake calc. When the ends are disconnected I
had a clause to break the smoothsnake calc at the last endpoint, however this stopped short of
actually computing a smooth snake point to the last endpoint, which meant that the last smoothsnake
point was not quite to the selected point location (and the difference in location was noticable
because the adjusted point was so far away from its neighbor snake point).
- also I had the inwardConstraint on which forced the snake to the far edge
- this probably solved the bug from 5/1 since what had happened was that find_opt took the erroneous, short
last smoothsnake point, and then found it's outer edge point.
2. along the smooth outer edge of the lung, when snaking to a binary image (mask), all the snake points
seem to be ~2 pixels outside the actual border and all will not move even when adjusted to do so.
- much of this was the inwardConstraint work. I turned it off and the thing is better.
WO 6/5/2012 found the line tot_energy += tot_ext+tot_int was inside the calc loop, so that the calc was compounded (the first pt energy counted NPT times!), resulting in the total_energy being way too high
6/6/2012 when saving left hemi-lung points (to do right afterwards), saves the points with a generic name such that
the subsequent right side reads those in .. need to have separate file names for the right and left sides.
-- done
10/30/2012 for UF lung SBRT subjects, the saved filename for all slices is CT1_right.points -- not parsing the file name well
WO 2/28/2013 trying to make this run more like the hermit snake, which is more
advanced and shows only the original window; and not the edge image. And relies on arrayDisplay snakeAd rather
then the canvas and window directly.
Sort-of solved problem that snake would write to edgeAD but not remain (same for additional display AD). The error
is somehow related to the fact that when the mouse moves a selected point, UpdateScreen() is called several times
for each interaction. Perhaps the drawing just can't keep up. My 'solution' was to create a flag that is set 'On'
when an actual selection is made (selectionUpdated=true) or an attribute is changed (attributeUpdated=true). Then
inside UpdateScreen is both runs snakeAd.clearOverlays() and draws to the other ADs, and sets the flags to false.
This achieves the drawing to occur only once for each interaction. The proof being that the snakes are now seen
and there is no infinite loop through updateScreen().
A remaining annoyance is when the slice is changed in the snakeAd, the other slices do follow but the snake is
not seen on them until updateSelection or updateAttribute is invoked.
GUI for snake rendering and interaction
11/6/2014 have now created a truncated ellipse Roi for heart LV long axis segmentation. Now need snake to use that
Roi.
Modifier and Type | Class and Description |
---|---|
class |
InteractiveSnake.Candidates |
class |
InteractiveSnake.SmoothSnake |
class |
InteractiveSnake.Snake |
class |
InteractiveSnake.SnakeStack |
Modifier and Type | Field and Description |
---|---|
protected static int |
absGradient |
protected float |
cur_ptSep |
protected int |
cur_ptShift |
protected float |
curEnergy_Bend |
protected float |
curEnergy_Pressure |
protected float |
curEnergy_Stretch |
protected boolean |
DoFullyManual |
protected boolean |
enableCreateMaskSaveAsDicom |
java.lang.String |
filename_addon |
protected static int |
gradientIn |
protected static int |
gradientOut |
protected int |
gradientType |
protected java.lang.String |
Label |
protected ij.gui.Roi |
origSelectedRoi |
protected boolean |
ProhibitInwardPoints |
protected boolean |
runAsStandAlone |
protected boolean |
saveWindows |
boolean |
showEdgeImg |
protected boolean |
ShowLabels |
protected ArrayDisplay |
snakeAd |
protected GenericRecallableDialog |
snakegd |
protected Point3Dviewer |
snakeptviewer |
protected InteractiveSnake.SnakeStack |
snakeStack |
boolean |
useAdditionalDrawingAD |
working_canvas
Constructor and Description |
---|
InteractiveSnake() |
Modifier and Type | Method and Description |
---|---|
short[][][] |
computeEdgeImage(byte[][][] A) |
short[][][] |
computeEdgeImage(short[][][] A) |
boolean[][][] |
CreateMask() |
void |
init(ij.ImagePlus passedimp)
snakestack == null is flag for interactiveSnake running as a stand-alone program
|
protected void |
InitSnakeDisplay(ArrayDisplay curAd)
similar to version from hermitsnake.
|
protected void |
InitSnakeDisplay(java.lang.String imglabel,
ArrayDisplay curAd) |
void |
refreshScreen() |
void |
run(ij.ImagePlus passedimp) |
void |
run(java.lang.String arg)
This method is called when the plugin is loaded.
|
void |
run(java.lang.String arg,
ij.ImagePlus passedimp) |
void |
setFilename_addon(java.lang.String fna) |
void |
showAbout() |
void |
spaceWindowsOnScreen() |
java.lang.String |
toString() |
void |
UpdateAttributes(float curEnergy_Bend,
float curEnergy_Stretch,
float curEnergy_Pressure,
float cur_ptSep,
int cur_ptShift,
boolean doManually) |
void |
UpdateScreen()
invoked most commonly within here, but also by ScreenSelectorCanvas.updateScreen()
|
void |
UpdateSelection(int scrX,
int scrY,
java.lang.String type_str) |
adjustCurSlice, cropToObjectROI, customButFunc, customChoiceFunc, findClosestMark, get3Dview, get3DviewOfmark, getObjectMaskFromFiles, getObjectMaskFromFiles, getPtInputDirInfo, redisplay, resetwidgets, runGUI, setGUIWinLevelWidgets, setNewSlice, setNewStudy, setupImg, setupImg, setupImg, setupImg, updateMarkingPanel, UpdateSelectionImageReviewer
keyPressed, mouseDragged, mouseMoved, mousePressed, mouseReleased
protected boolean runAsStandAlone
protected boolean enableCreateMaskSaveAsDicom
protected ij.gui.Roi origSelectedRoi
protected boolean saveWindows
protected ArrayDisplay snakeAd
protected InteractiveSnake.SnakeStack snakeStack
protected java.lang.String Label
protected float curEnergy_Bend
protected float curEnergy_Stretch
protected float curEnergy_Pressure
protected float cur_ptSep
protected int cur_ptShift
protected GenericRecallableDialog snakegd
protected boolean ShowLabels
protected boolean DoFullyManual
protected boolean ProhibitInwardPoints
public java.lang.String filename_addon
protected int gradientType
protected static int gradientOut
protected static int gradientIn
protected static int absGradient
public boolean showEdgeImg
public boolean useAdditionalDrawingAD
protected Point3Dviewer snakeptviewer
public void showAbout()
public void init(ij.ImagePlus passedimp)
public void run(ij.ImagePlus passedimp)
public void run(java.lang.String arg)
ij.plugin.PlugIn
run
in interface ij.plugin.PlugIn
run
in class ImageReviewer
public void run(java.lang.String arg, ij.ImagePlus passedimp)
run
in class ImageReviewer
public void spaceWindowsOnScreen()
spaceWindowsOnScreen
in class ImageReviewer
public java.lang.String toString()
toString
in class ImageReviewer
protected void InitSnakeDisplay(ArrayDisplay curAd)
protected void InitSnakeDisplay(java.lang.String imglabel, ArrayDisplay curAd)
public short[][][] computeEdgeImage(byte[][][] A)
public short[][][] computeEdgeImage(short[][][] A)
public void UpdateAttributes(float curEnergy_Bend, float curEnergy_Stretch, float curEnergy_Pressure, float cur_ptSep, int cur_ptShift, boolean doManually)
public void refreshScreen()
public void UpdateScreen()
UpdateScreen
in class ImageReviewer
public void UpdateSelection(int scrX, int scrY, java.lang.String type_str)
UpdateSelection
in class ImageReviewer
public boolean[][][] CreateMask()
public void setFilename_addon(java.lang.String fna)