def save(pyramid, keys, root): sizes, octave = pyramid[0] octave = filters.norm(octave, 5, 5, 0, 255) key_levels = binby(keys, lambda x: int(x.octave)) for l, level in enumerate(octave): drawn = level if l in key_levels: drawn = keypoints.draw(level, key_levels[l]) save(drawn, pyfs.join(root, "%f.png" % sizes[l]), norm=False)
def mesa(image, start=2.0, stop=None, levels=10, ring=1.05, psize=1, edge_threshold=2, threshold=1.0): stop = stop or min(image.shape) / 4 print("mesa finding image particles:") print(" image dimensions:", image.shape) print(" from %f to %f" % (start, stop)) print(" over %d levels" % (levels)) print(" peak neighbor size: %d" % (psize)) image = filters.norm(image, 5, 5, 0.0, 1.0) pyramid = mkpyramid(image, start, stop, levels, ring) features = find_features(pyramid, threshold, edge_threshold, psize) return features
def load(path, norm=False, supress=False): with open(path, "rb") as fd: header = readHeader(fd) fd.seek(int(header["LABBYT"])) rows = int(header["NX"]) cols = int(header["NY"]) if int(header["NZ"]) != 1: raise ValueError("spider volumes not supported") if int(header["ISTACK"]) != 0: raise ValueError("spider stacks not supported") data = np.fromfile(fd, dtype="f4") if data.size != rows * cols: raise ValueError("spider image has bad/incomplete data") if supress: data = filters.supress(data, *supress) if norm: data = filters.norm(data, *norm) return data.reshape([cols, rows])
def load(path, supress=False, norm=False): endian = '<' with open(path, "rb") as fd: header = np.fromfile(fd, dtype=MRCHeader, count=1)[0] header = header.newbyteorder(endian) # memory map using copy on write mode # with offset starting after the header # and reverse dimensions from header if header["mode"] not in MRCModes: endian = '>' header = header.newbyteorder(endian) data = np.memmap(fd, mode="c", offset=MRCHeader.itemsize + header['extended_header'], dtype=MRCModes[header["mode"]], shape=tuple(header["dims"][::-1])) data = data.newbyteorder(endian) if supress: data = filters.supress(data, *supress) if norm: data = filters.norm(data, *norm) return data
def save(image, path, norm=(0.01, 0.01, 0, 255)): if norm: image = filters.norm(image, *norm) with pyfs.shadow(path): cv2.imwrite(path, image.astype('uint8')) return path
def save(image, keys, root): image = filters.norm(image, 5, 5, 0, 255) key_sizes = binby(keys, lambda x: int(x.size)) for size in key_sizes: drawn = keypoints.draw(image, key_sizes[size]) save(drawn, pyfs.join(root, "%f.png"%size))
def save_octave(radii, octave, root): levels = filters.norm(octave, 1, 1, 0, 255) for size, level in zip(radii, levels): save(level, pyfs.join(root, "%2.2f.png"%(size)), norm=False)