from matplotlib import pyplot as plt from colloids import track def draw_circles(xs, ys, rs, **kwargs): for x, y, r in zip(xs, ys, rs): circle = plt.Circle((x, y), radius=r, **kwargs) plt.gca().add_patch(circle) im = plt.imread('droplets.jpg') finder = track.MultiscaleBlobFinder(im.shape, Octave0=False, nbOctaves=4) centers = finder(im, k=2) draw_circles(centers[:, 0], centers[:, 1], centers[:, 2], facecolor='none', edgecolor='g') plt.imshow(im, 'hot') plt.show()
pattern = filename path, name = split(filename) outpattern = join(path,'treated_'+name) divpattern = splitext(join(path,'bgdiv_'+name))[0]+'.jpg' filename = pattern%0 #read the first image im = imread(filename) if im.ndim ==0: im = readTIFF16(filename) cent = np.zeros_like(im) if len(sys.argv) >2: sigma = float(sys.argv[2]) else: #estimate the best blurring radius finder = track.MultiscaleBlobFinder(im.shape, nbOctaves=100) centers = finder(im, k=1.6, Octave0=False, removeOverlap=False) sigma = 1.6*2**(np.argmax([ oc.binary[1:-1].sum(-1).sum(-1) for oc in finder.octaves[1:] ])/3.0) #create a monoscale Crocker & Grier finder finder = track.CrockerGrierFinder(im.shape) #background background = track.gaussian_filter(np.array(im, float), 10*sigma) background[background==0] = 1.0 #drift or flow overlap = 2**int(np.log(20*sigma)/np.log(2)) window_size = 2*overlap #having 3 subwindows is not enought use_subgrid_phasecor = 5*overlap < min(im.shape)
import numpy as np def draw_circles(centres, z_chosen, **kwargs): for (x, y, z, r) in centres[:, :4]: dz = np.abs(z - z_chosen) if dz < r: r_real = np.sqrt(r**2 - dz**2) circle = plt.Circle((x, y), radius=r_real, **kwargs) plt.gca().add_patch(circle) im = np.load('hard_sphere_volume.npy') im = np.moveaxis(im, -1, 0) finder = track.MultiscaleBlobFinder(im.shape, Octave0=False, nbOctaves=10, nbLayers=5) centers = finder(im, k=1.7) print(centers.shape) im = np.moveaxis(im, 0, -1) z = 30 draw_circles(centers, z, facecolor='none', edgecolor='teal', lw=4) plt.imshow(im[:, :, z], 'hot') plt.show() s = track.radius2sigma(centers[:, -2], dim=2) bonds, dists = get_bonds(positions=centers[:, :-2], radii=centers[:, -2],