Python skimage.__version__() Examples
The following are 7
code examples of skimage.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
skimage
, or try the search function
.
Example #1
Source File: utils.py From image-segmentation with MIT License | 6 votes |
def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True, preserve_range=False, anti_aliasing=False, anti_aliasing_sigma=None): '''A wrapper for Scikit-Image resize(). Scikit-Image generates warnings on every call to resize() if it doesn't receive the right parameters. The right parameters depend on the version of skimage. This solves the problem by using different parameters per version. And it provides a central place to control resizing defaults. ''' if LooseVersion(skimage.__version__) >= LooseVersion('0.14'): # New in 0.14: anti_aliasing. Default it to False for backward # compatibility with skimage 0.13. return skresize( image, output_shape, order=order, mode=mode, cval=cval, clip=clip, preserve_range=preserve_range, anti_aliasing=anti_aliasing, anti_aliasing_sigma=anti_aliasing_sigma) else: return skresize( image, output_shape, order=order, mode=mode, cval=cval, clip=clip, preserve_range=preserve_range)
Example #2
Source File: deviceconfig.py From MONAI with Apache License 2.0 | 5 votes |
def get_config_values(): """ Read the package versions into a dictionary. """ output = OrderedDict() output["MONAI"] = monai.__version__ output["Python"] = sys.version.replace("\n", " ") output["Numpy"] = np.version.full_version output["Pytorch"] = torch.__version__ return output
Example #3
Source File: deviceconfig.py From MONAI with Apache License 2.0 | 5 votes |
def get_torch_version_tuple(): """ Returns: tuple of ints represents the pytorch major/minor version. """ return tuple([int(x) for x in torch.__version__.split(".")[:2]])
Example #4
Source File: bm_comp_perform.py From BIRL with BSD 3-Clause "New" or "Revised" License | 5 votes |
def main(path_out='', nb_runs=5): """ the main entry point :param str path_out: path to export the report and save temporal images :param int nb_runs: number of trails to have an robust average value """ logging.info('Running the computer benchmark.') skimage_version = skimage.__version__.split('.') skimage_version = tuple(map(int, skimage_version)) if skimage_version < SKIMAGE_VERSION: logging.warning('You are using older version of scikit-image then we expect.' ' Please upadte by `pip install -U --user scikit-image>=%s`', '.'.join(map(str, SKIMAGE_VERSION))) hasher = hashlib.sha256() hasher.update(open(__file__, 'rb').read()) report = { 'computer': computer_info(), 'created': str(datetime.datetime.now()), 'file': hasher.hexdigest(), 'number runs': nb_runs, 'python-version': platform.python_version(), 'skimage-version': skimage.__version__, } report.update(measure_registration_single(path_out, nb_iter=nb_runs)) nb_runs_ = max(1, int(nb_runs / 2.)) report.update(measure_registration_parallel(path_out, nb_iter=nb_runs_)) path_json = os.path.join(path_out, NAME_REPORT) logging.info('exporting report: %s', path_json) with open(path_json, 'w') as fp: json.dump(report, fp) logging.info('\n\t '.join('%s: \t %r' % (k, report[k]) for k in report))
Example #5
Source File: conf.py From oggm with BSD 3-Clause "New" or "Revised" License | 5 votes |
def write_index(): """This is to write the docs for the index automatically.""" here = os.path.dirname(__file__) filename = os.path.join(here, '_generated', 'version_text.txt') try: os.makedirs(os.path.dirname(filename)) except FileExistsError: pass text = text_version if '+' not in oggm.__version__ else text_dev with open(filename, 'w') as f: f.write(text)
Example #6
Source File: utils.py From fcn with MIT License | 4 votes |
def get_tile_image(imgs, tile_shape=None, result_img=None, margin_color=None): """Concatenate images whose sizes are different. @param imgs: image list which should be concatenated @param tile_shape: shape for which images should be concatenated @param result_img: numpy array to put result image """ def resize(*args, **kwargs): # anti_aliasing arg cannot be passed to skimage<0.14 # use LooseVersion to allow 0.14dev. if LooseVersion(skimage.__version__) < LooseVersion('0.14'): kwargs.pop('anti_aliasing', None) return skimage.transform.resize(*args, **kwargs) def get_tile_shape(img_num): x_num = 0 y_num = int(math.sqrt(img_num)) while x_num * y_num < img_num: x_num += 1 return y_num, x_num if tile_shape is None: tile_shape = get_tile_shape(len(imgs)) # get max tile size to which each image should be resized max_height, max_width = np.inf, np.inf for img in imgs: max_height = min([max_height, img.shape[0]]) max_width = min([max_width, img.shape[1]]) # resize and concatenate images for i, img in enumerate(imgs): h, w = img.shape[:2] dtype = img.dtype h_scale, w_scale = max_height / h, max_width / w scale = min([h_scale, w_scale]) h, w = int(scale * h), int(scale * w) img = resize( image=img, output_shape=(h, w), mode='reflect', preserve_range=True, anti_aliasing=True, ).astype(dtype) if len(img.shape) == 3: img = centerize(img, (max_height, max_width, 3), margin_color) else: img = centerize(img, (max_height, max_width), margin_color) imgs[i] = img return _tile_images(imgs, tile_shape, result_img)
Example #7
Source File: LST.py From python-urbanPlanning with MIT License | 4 votes |
def LSTClustering(self): # 参考“Segmenting the picture of greek coins in regions”方法,Author: Gael Varoquaux <gael.varoquaux@normalesup.org>, Brian Cheung # License: BSD 3 clause orig_coins=self.LST # these were introduced in skimage-0.14 if LooseVersion(skimage.__version__) >= '0.14': rescale_params = {'anti_aliasing': False, 'multichannel': False} else: rescale_params = {} smoothened_coins = gaussian_filter(orig_coins, sigma=2) rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",**rescale_params) # Convert the image into a graph with the value of the gradient on the # edges. graph = image.img_to_graph(rescaled_coins) # Take a decreasing function of the gradient: an exponential # The smaller beta is, the more independent the segmentation is of the # actual image. For beta=1, the segmentation is close to a voronoi beta = 10 eps = 1e-6 graph.data = np.exp(-beta * graph.data / graph.data.std()) + eps # Apply spectral clustering (this step goes much faster if you have pyamg # installed) N_REGIONS = 200 for assign_labels in ('discretize',): # for assign_labels in ('kmeans', 'discretize'): t0 = time.time() labels = spectral_clustering(graph, n_clusters=N_REGIONS,assign_labels=assign_labels, random_state=42) t1 = time.time() labels = labels.reshape(rescaled_coins.shape) plt.figure(figsize=(5*3, 5*3)) plt.imshow(rescaled_coins, cmap=plt.cm.gray) for l in range(N_REGIONS): plt.contour(labels == l, colors=[plt.cm.nipy_spectral(l / float(N_REGIONS))]) plt.xticks(()) plt.yticks(()) title = 'Spectral clustering: %s, %.2fs' % (assign_labels, (t1 - t0)) print(title) plt.title(title) plt.show() ##基于卷积温度梯度变化界定冷区和热区的空间分布结构