def generate_probe_loc_image(norm_projection, probe_locs, imsave): """Generate an annotated image showing the probe locations as crosses.""" probe_loc_image = grayscale_to_rgb(norm_projection.image_array) for coords in probe_locs: x, y = coords c = random_rgb() draw_cross(probe_loc_image, x, y, c) imsave('probe_locations.png', probe_loc_image)
def hough_stuff(imsave): """Deprecated. Template matching works better.""" thresh = threshold_otsu(edges, mult=1.5) hough_radii = np.arange(1, 3, 1) hough_res = skimage.transform.hough_circle(thresh.image_array, hough_radii) hough_data = hough_res[0] + hough_res[1] #loc_array = peak_local_max(hough_data, min_distance=5, threshold_rel=0.5) cloc_array = peak_local_max(hough_data, min_distance=5, threshold_rel=0.5, indices=False) imsave('cloc.png', cloc_array) connected_components, n_cc = skimage.measure.label(cloc_array, neighbors=8, return_num=True) labels = np.unique(connected_components) annot = np.zeros((512, 512, 3), dtype=np.uint8) annot[:,:] = 255, 255, 255 annot[np.where(thresh.image_array)] = [0, 0, 0] def draw_cross(x, y, c): for xo in np.arange(-4, 5, 1): annot[x+xo, y] = c for yo in np.arange(-4, 5, 1): annot[x,y+yo] = c probe_locs = [] for label in labels: coord_list = zip(*np.where(connected_components == label)) probe_locs.append(coord_list[0]) for coords in probe_locs: x, y = coords c = random_rgb() draw_cross(x, y, c) imsave('probe_locations.png', annot) #print '\n'.join(thresh.history) return probe_locs