Created
March 10, 2014 04:55
-
-
Save hirokai/9459692 to your computer and use it in GitHub Desktop.
Nanodot spacing analysis by Delaunay triangulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getVal(table, i): | |
x = table.getValue('X', i) | |
y = table.getValue('Y', i) | |
return (x, y) | |
# Stub | |
def delaunay(coords): | |
return None | |
# imp is a thresholded image (binary image). | |
def find_dots(imp): | |
IJ.run(imp, "Set Measurements...", " centroid redirect=None decimal=2") | |
IJ.run(imp, "Analyze Particles...", "size=20-Infinity circularity=0.00-1.00 show=Ellipses display clear") | |
# Get a Results table. This content can be shown from Window -> Results | |
table = ResultsTable.getResultsTable() | |
# Get the number of rows. | |
n = table.getCounter() | |
# Call getVal to get every (x,y) coordinate. | |
return [getVal(table, i) for i in range(0, n)] | |
def main(): | |
path = "/Volumes/Macintosh HD/Dropbox/Groves Lab Data/SEM/130712 EML/20 80k.tiff" | |
imp = IJ.openImage(path) | |
th_imp = threshold(imp) | |
coords = find_dots(th_imp) | |
triangles = delaunay(coords) | |
# Show an original image and a thresholded image. | |
imp.show() | |
th_imp.show() | |
def threshold(imp): | |
imp2 = imp.duplicate() | |
ip2 = imp2.getProcessor() | |
IJ.run(imp2, "Auto Threshold", "method=RenyiEntropy white") | |
IJ.run(imp2, "Convert to Mask", "") | |
return imp2 | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment