From 86ad9cfd300e9f022d0e71a21152a0f8b07c07bf Mon Sep 17 00:00:00 2001 From: sfop Date: Thu, 18 Aug 2016 16:13:38 +0200 Subject: [PATCH] Startup --- script/ImageStats.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 script/ImageStats.py diff --git a/script/ImageStats.py b/script/ImageStats.py new file mode 100644 index 0000000..1b381d8 --- /dev/null +++ b/script/ImageStats.py @@ -0,0 +1,33 @@ +from ijutils import * +from ch.psi.pshell.imaging.Overlays import * +import ch.psi.pshell.imaging.Pen as Pen + +def wait_next(): + camera.waitNext(250) + +def get_centroid(): + bi = image.getImage() + op = show_panel(bi, "Original") + if bi is None: + return None + ip = load_image(bi) + grayscale(ip) + invert(ip) + gaussian_blur(ip) + auto_threshold(ip) + + #binary_erode(ip) + show_panel(ip.getBufferedImage(), "Image") + (results,output_img)=analyse_particles(ip, 1000,20000, print_table=True) + op.clearOverlays() + show_panel(output_img.getBufferedImage(), "Outlines") + if results.size()>0: + print results + centroid = (results.getValue("XM",0), results.getValue("YM",0)) + ov = Crosshairs(Pen(java.awt.Color.ORANGE), java.awt.Point(int(centroid[0]),int(centroid[1])), java.awt.Dimension(15,15)) + op.addOverlay(ov) + return centroid + + +get_centroid() +