def anaParticles(imp, minSize, maxSize, minCirc, bHeadless=True): """anaParticles(imp, minSize, maxSize, minCirc, bHeadless=True) Analyze particles using a watershed separation. If headless=True, we cannot redirect the intensity measurement to the original immage becuae it is never displayed. If we display the original, we can and get the mean gray level. We may then compute the particle contrast from the measured Izero value for the image. No ability here to draw outlines on the original.""" strName = imp.getShortTitle() imp.setTitle("original") ret = imp.duplicate() IJ.run(ret, "Enhance Contrast", "saturated=0.35") IJ.run(ret, "8-bit", "") IJ.run(ret, "Threshold", "method=Default white") IJ.run(ret, "Watershed", "") rt = ResultsTable() # strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3" # N.B. redirect will not work without a displayed image, so we cannot use a gray level image if bHeadless == True: strSetMeas = "area mean modal min center perimeter bounding fit shape feret's decimal=3" else: imp.show() strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3" IJ.run("Set Measurements...", strSetMeas) # note this doies not get passed directly to ParticleAnalyzer, so # I did this, saved everything and looked for the measurement value in ~/Library/Preferences/IJ_Prefs.txt # measurements=27355 # meas = Measurements.AREA + Measurements.CIRCULARITY + Measurements.PERIMETER + Measurements.SHAPE_DESCRIPTORS # didn't work reliably meas = 27355 pa = ParticleAnalyzer(0, meas, rt, minSize, maxSize, minCirc, 1.0); pa.analyze(ret); rt.createTableFromImage(ret.getProcessor()) return [ret, rt]
def anaParticles(imp, minSize, maxSize, minCirc): strName = imp.getShortTitle() imp.setTitle("original") ret = imp.duplicate() IJ.run(ret, "Enhance Contrast", "saturated=0.35") IJ.run(ret, "8-bit", "") IJ.run(ret, "Threshold", "method=Default white") IJ.run(ret, "Watershed", "") rt = ResultsTable() # strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3" # N.B. redirect will not work without a displayed image, so we cannot use a gray level image strSetMeas = "area mean modal min center perimeter bounding fit shape feret's decimal=3" IJ.run("Set Measurements...", strSetMeas) # note this doies not get passed directly to ParticleAnalyzer, so # I did this, saved everything and looked for the measurement value in ~/Library/Preferences/IJ_Prefs.txt # measurements=27355 # meas = Measurements.AREA + Measurements.CIRCULARITY + Measurements.PERIMETER + Measurements.SHAPE_DESCRIPTORS # didn't work reliably meas = 27355 pa = ParticleAnalyzer(0, meas, rt, minSize, maxSize, minCirc, 1.0); pa.analyze(ret); rt.createTableFromImage(ret.getProcessor()) return [ret, rt]
def ana_particles(imp, minSize, maxSize, minCirc, bHeadless=True): """ana_particles(imp, minSize, maxSize, minCirc, bHeadless=True) Analyze particles using a watershed separation. If headless=True, we cannot redirect the intensity measurement to the original image because it is never displayed. If we display the original, we can and get the mean gray level. We may then compute the particle contrast from the measured Izero value for the image. No ability here to draw outlines on the original. """ strName = imp.getShortTitle() imp.setTitle("original") ret = imp.duplicate() ret.setTitle("work") IJ.run(ret, "Enhance Contrast", "saturated=0.35") IJ.run(ret, "8-bit", "") IJ.run(ret, "Threshold", "method=Default white") IJ.run(ret, "Watershed", "") rt = ResultsTable() # strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3" # N.B. redirect will not work without a displayed image, so we cannot use a gray level image if bHeadless == True: strSetMeas = "area mean modal min center perimeter bounding fit shape feret's decimal=3" else: imp.show() strSetMeas = "area mean modal min center perimeter bounding fit shape feret's redirect='original' decimal=3" IJ.run("Set Measurements...", strSetMeas) # note this does not get passed directly to ParticleAnalyzer, so # I did this, saved everything and looked for the measurement value in ~/Library/Preferences/IJ_Prefs.txt # measurements=27355 # meas = Measurements.AREA + Measurements.CIRCULARITY + Measurements.PERIMETER + Measurements.SHAPE_DESCRIPTORS # didn't work reliably meas = 27355 pa = ParticleAnalyzer(0, meas, rt, minSize, maxSize, minCirc, 1.0) pa.analyze(ret) rt.createTableFromImage(ret.getProcessor()) return [ret, rt]