import math from ijutils import * DIAM_1 = 80 DIAM_2 = 550 DETECT_THRESHOLD = 10 #PIXELS renderer=show_panel(image) renderer.setMarker(None); #Image Loading ip = load_image(image.output, title="Image") aux = grayscale(ip, in_place=False) #invert(aux); px1 = int(pow(DIAM_1/2,2) * math.pi) px2 = int(pow(DIAM_2/2,2) * math.pi) #aux.show() #binary_open(aux); aux.repaintWindow() ti = auto_threshold(aux, dark_background=False, in_place=False) #; aux.repaintWindow() #ti.show() #binary_fill_holes(ti) #ti.repaintWindow() (res1,out1)=analyse_particles(ti, px1/2, px1*2, \ fill_holes = False, exclude_edges = True, print_table=True, \ output_image = "outlines", minCirc = 0.8, maxCirc = 1.0) #out1.show() ti = auto_threshold(aux, dark_background=True, in_place=False) #; aux.repaintWindow() (res2,out2)=analyse_particles(ti, px2/2, px2*2, \ fill_holes = False, exclude_edges = True, print_table=True, \ output_image = "outlines", minCirc = 0.8, maxCirc = 1.0) #output_img.show() if res1.size() == res2.size() == 1: x1,y1 = res1.getValue("XM", 0), res1.getValue("YM", 0) x2,y2 = res2.getValue("XM", 0), res2.getValue("YM", 0) if abs(x1-x2) <= DETECT_THRESHOLD and abs(y1-y2) <= DETECT_THRESHOLD: print("Detected: ", (x1, y1)) renderer=show_panel(image) p = Point(int(x1),int(y1)) ov = Overlays.Crosshairs(renderer.getPenProfile(), p, Dimension(-1, -1)) renderer.setMarker(ov);