Created
September 10, 2015 01:58
-
-
Save hirokai/a3786024afbca6c9f5fb to your computer and use it in GitHub Desktop.
Thresholding and measuring circles for scope calibration
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
from ij import IJ | |
from ij.measure import ResultsTable | |
from ij.plugin.filter import ParticleAnalyzer | |
import time | |
def analyze(path): | |
IJ.open(path) | |
IJ.run("16-bit"); | |
IJ.run("Auto Threshold", "method=Minimum"); | |
IJ.run("Invert"); | |
IJ.run("Set Measurements...", "area centroid bounding redirect=None decimal=3"); | |
IJ.run("Analyze Particles...", "size=100-Infinity circularity=0.50-1.00 show=Outlines display clear"); | |
time.sleep(1) | |
rt = ResultsTable.getResultsTable() | |
return rt | |
def main(): | |
file_nums = range(128,184) | |
for count, n in enumerate(file_nums): | |
path = '/path/to/%05d.JPG' % n | |
rt = analyze(path) | |
if count == 0: | |
print(rt.getColumnHeadings()) | |
for i in range(0,rt.size()): | |
s = rt.getRowAsString(i) | |
cs = s.split('\t') | |
if -300 < (float(cs[2]) - 640) < 300 and -200 < (float(cs[3]) - 480) < 200: | |
cs[0] = n | |
print('\t'.join(map(str,cs))) | |
IJ.run('Close All') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment