本文整理汇总了Python中skimage.io.use_plugin函数的典型用法代码示例。如果您正苦于以下问题:Python use_plugin函数的具体用法?Python use_plugin怎么用?Python use_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use_plugin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _find_working_imread
def _find_working_imread(modes=IMREAD_MODES):
"Finds an image-reading mode that works; returns the name and a function."
if isinstance(modes, str_types):
modes = [modes]
for mode in modes:
try:
if mode.startswith('skimage-'):
from skimage.io import use_plugin, imread
use_plugin(mode[len('skimage-'):])
elif mode == 'cv2':
import cv2
def imread(f):
img = cv2.imread(f)
if img.ndim == 3:
b, g, r = np.rollaxis(img, axis=-1)
return np.dstack([r, g, b])
return img
elif mode == 'matplotlib':
import matplotlib.pyplot as mpl
imread = lambda f: mpl.imread(f)[::-1]
return mode, imread
except ImportError:
pass
else:
raise ImportError("couldn't import any of {}".format(', '.join(modes)))
开发者ID:zzmjohn,项目名称:py-sdm,代码行数:28,代码来源:extract_image_features.py
示例2: __init__
def __init__(self, seg_dir, cell_wall_dir, measurement_dir, out_dir, out_prefix):
use_plugin('freeimage')
self.reconstructed_cells = []
self.selected_points = []
self.segmentation_maps = load_segmentation_maps(seg_dir)
self.cell_wall_images = self.get_images(cell_wall_dir)
self.measurement_images = self.get_images(measurement_dir)
self.out_dir = out_dir
self.out_prefix = out_prefix
self.segment_me_dir = os.path.join(out_dir, 'segment_me')
self.answer_dir = os.path.join(out_dir, 'answers')
for d in (self.out_dir, self.segment_me_dir, self.answer_dir):
if not os.path.isdir(d):
os.mkdir(d)
self.xdim, self.ydim = self.measurement_images[0].shape
start = time()
self.reconstruction = Reconstruction(self.segmentation_maps, start=0)
for z in range(0, len(self.segmentation_maps)-1):
self.reconstruction.extend(z)
elapsed = ( time() - start ) / 60
print('Reconstruction done {} minutes.'.format(elapsed))
开发者ID:JIC-CSB,项目名称:root-image-analysis,代码行数:27,代码来源:generate_validation_set.py
示例3: test_manual_image_creation_from_file
def test_manual_image_creation_from_file(self):
from jicbioimage.core.image import Image
# Preamble: let us define the path to a TIFF file and create a numpy
# array from it.
# from libtiff import TIFF
# tif = TIFF.open(path_to_tiff, 'r')
# ar = tif.read_image()
path_to_tiff = os.path.join(DATA_DIR, 'single-channel.ome.tif')
use_plugin('freeimage')
ar = imread(path_to_tiff)
# It is possible to create an image from a file.
image = Image.from_file(path_to_tiff)
self.assertEqual(len(image.history), 0)
self.assertEqual(image.history.creation,
'Created Image from {}'.format(path_to_tiff))
# With name...
image = Image.from_file(path_to_tiff, name='Test1')
self.assertEqual(image.history.creation,
'Created Image from {} as Test1'.format(path_to_tiff))
# Without history...
image = Image.from_file(path_to_tiff, log_in_history=False)
self.assertEqual(len(image.history), 0)
# It is worth noting the image can support more multiple channels.
# This is particularly important when reading in images in rgb format.
fpath = os.path.join(DATA_DIR, 'tjelvar.png')
image = Image.from_file(fpath)
self.assertEqual(image.shape, (50, 50, 3))
开发者ID:JIC-CSB,项目名称:jicbioimage.core,代码行数:34,代码来源:Image_functional_tests.py
示例4: test_imread_collection_single_MEF
def test_imread_collection_single_MEF():
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'multi.fits')
ic1 = io.imread_collection(testfile)
ic2 = io.ImageCollection([(testfile, 1), (testfile, 2), (testfile, 3)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
开发者ID:amueller,项目名称:scikit-image,代码行数:7,代码来源:test_fits.py
示例5: apply_mask
def apply_mask(input_file, mask_file, output_file):
use_plugin('pil')
# TODO - shape mismatches
input_image = imread(input_file)
mask_image = imread(mask_file)
logger.info('Input image shape: {}'.format(input_image.shape))
logger.info('Mask image shape: {}'.format(mask_image.shape))
xdim, ydim, _ = input_image.shape
output_image = np.zeros((xdim, ydim), np.uint8)
mask_xs, mask_ys = np.where(mask_image == 255)
mask_zs = np.zeros(mask_xs.shape, np.uint8)
mask_locations = mask_xs, mask_ys, mask_zs
output_locations = (mask_xs, mask_ys)
output_image[output_locations] = input_image[mask_locations]
imsave(output_file, output_image)
开发者ID:JIC-CSB,项目名称:root-image-analysis,代码行数:25,代码来源:apply_mask.py
示例6: setup_module
def setup_module(self):
"""The effect of the `plugin.use` call may be overridden by later imports.
Call `use_plugin` directly before the tests to ensure that PIL is used.
"""
try:
use_plugin('pil')
except ImportError:
pass
开发者ID:Greenwicher,项目名称:scikit-image,代码行数:9,代码来源:test_pil.py
示例7: test_imread_collection_MEF_and_simple
def test_imread_collection_MEF_and_simple():
io.use_plugin('fits')
testfile1 = os.path.join(data_dir, 'multi.fits')
testfile2 = os.path.join(data_dir, 'simple.fits')
ic1 = io.imread_collection([testfile1, testfile2])
ic2 = io.ImageCollection([(testfile1, 1), (testfile1, 2),
(testfile1, 3), (testfile2, 0)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
开发者ID:amueller,项目名称:scikit-image,代码行数:9,代码来源:test_fits.py
示例8: ensemble_average_images
def ensemble_average_images(dirin,pattern,filout):
"""A function to do an ensemble average of images and a spatial average of this ensemble average
Parameters
----------
dirin: str
. Input directory
pattern: str
Input Pattern images to average
filout: str
Output filename
"""
#to be able to read high precision images (e.g. 16bits)
io.use_plugin('freeimage')
#im=io.imread("B00001_0.tif",as_grey=True)
#plt.imshow(im)
#plt.show()
#pattern="B0*_0.tif"
#dirin='/media/HDImage/SMARTEOLE/PIV-Nov2015-TIF/PIV_10ms_000lmin_05deg_z539mm_dt35us_1000im/'
# list automatically the file names
list_image=sorted( glob.glob( os.path.join( os.path.abspath(dirin), pattern ) ) )
# Read this list
imlist=io.imread_collection(list_image)
#not possible to do the average like this: meanimg=sum(imlist)/len(imlist)
#plt.imshow(imlist[0],clim=(0,1000),cmap=cm.gray)
#plt.show()
# Accumulation of pixel value in float type (to avoid saturation)
fimlist=imlist[0].astype(float)
for i in range(len(imlist)-1):
fimlist += imlist[i+1].astype(float)
#plt.hist(fimlist[0].ravel(),bins=10000,range=(30,5500))
#plt.show()
#mean value with float rounded with np.rint()
meanimg_ens=np.rint(fimlist/len(imlist))
#convert to integer
meanimg_int=meanimg_ens.astype(np.uint16)
#mean spatial value rounded with np.rint()
meanimg_space=np.rint(np.mean(meanimg_ens))
#convert to integer
meanimg_space=meanimg_space.astype(np.uint16)
# Dimensionless mean value
mean_out=(np.rint(meanimg_ens/np.mean(meanimg_ens))).astype(np.uint16)
#plt.imshow(meanimg,clim=(0,100),cmap=cm.gray)
#plt.show()
#io.imsave(filout,meanimg_int)
# save in a file
io.imsave(filout,mean_out)
return mean_out;
开发者ID:alexlib,项目名称:m_openpiv,代码行数:57,代码来源:filters.py
示例9: setup_module
def setup_module(self):
"""The effect of the `plugin.use` call may be overridden by later imports.
Call `use_plugin` directly before the tests to ensure that freeimage is
used.
"""
try:
sio.use_plugin('freeimage')
except RuntimeError:
pass
开发者ID:AtonLerin,项目名称:maya_python_packages,代码行数:10,代码来源:test_freeimage.py
示例10: test_fits_plugin_import
def test_fits_plugin_import():
# Make sure we get an import exception if PyFITS isn't there
# (not sure how useful this is, but it ensures there isn't some other
# error when trying to load the plugin)
try:
io.use_plugin('fits')
except ImportError:
assert pyfits_available == False
else:
assert pyfits_available == True
开发者ID:amueller,项目名称:scikit-image,代码行数:10,代码来源:test_fits.py
示例11: reconstruct_and_measure
def reconstruct_and_measure(seg_dir, measure_dir,
out_dir, results_file,
start_z, end_z):
logger.info('Segmentation dir: {}'.format(seg_dir))
logger.info('Measurement dir: {}'.format(measure_dir))
logger.info('Output dir: {}'.format(out_dir))
logger.info('Results file: {}'.format(results_file))
use_plugin('freeimage')
smaps = load_segmentation_maps(seg_dir)
idata = load_intensity_data(measure_dir)
xdim, ydim = idata[0].shape
if start_z is None:
start_z = 0
if end_z is None:
end_z = len(smaps)-1 # Minus 1 is intentional; need to be able to extend one more z-stack
logger.info('Start z: {:d}'.format(start_z))
logger.info('End z: {:d}'.format(end_z))
r = Reconstruction(smaps, start=start_z)
logger.debug('Reconstruction instance: {}'.format(r))
for z in range(start_z, end_z):
r.extend(z)
rcells = r.cells_larger_then(3)
# Write the mask images
mask_fpaths = get_mask_output_fpaths(seg_dir, out_dir, start_z, end_z)
generate_reconstruction_mask(mask_fpaths, xdim, ydim, rcells, start_z, end_z)
# Calculate total area
sum_segmentation_area = sum_segmentation_dir(seg_dir)
with open(results_file, "w") as f:
f.write('mean_intensity,quartile_intensity,best_intensity,best_z,x,y,z,volume,zext,sum_seg_area\n')
for rcell in rcells:
x, y, z = rcell.centroid
mean_intensity = rcell.measure_mean_intensity(idata)
quartile_intensity = rcell.measure_quartile_intensity(idata)
best_intensity, best_z = rcell.measure_best_slice(idata)
volume = rcell.pixel_area
zext = rcell.z_extent
f.write("{},{},{},{},{},{},{},{},{},{}\n".format(
mean_intensity,
quartile_intensity,
best_intensity,
best_z,
x, y, z,
volume,
zext,
sum_segmentation_area))
开发者ID:JIC-CSB,项目名称:root-image-analysis,代码行数:55,代码来源:reconstruct_and_measure.py
示例12: main
def main():
import skimage.io as io
import sys
if len(sys.argv) != 2:
print "Usage: skivi <image-file>"
sys.exit(-1)
io.use_plugin('qt')
io.imshow(io.imread(sys.argv[1]), fancy=True)
io.show()
开发者ID:Teva,项目名称:scikits.image,代码行数:11,代码来源:skivi.py
示例13: _import_skimage_io
def _import_skimage_io():
"""
To import skimage io only when it is/can be used
"""
try:
from skimage import io as skio
skio.use_plugin('freeimage')
except ImportError as exc:
raise ImportError("Could not find the package skimage, its subpackage "
"io and the pluging freeimage which are required to support "
"several image formats. Error details: {0}".format(exc))
return skio
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:12,代码来源:io.py
示例14: open
def open(self):
#http://flockhart.virtualave.net/RBIF0100/regexp.html
if not self.filename.endswith(".pbm"):
io.use_plugin("freeimage")
self.data = io.imread(self.filename)
#self.data = self.data.astype("float64")
self.sizex = self.data.shape[0]
self.sizey = self.data.shape[1]
if self.filename.endswith("ppm"):
self.color = True
return self.data
开发者ID:nmoya,项目名称:ImageLibrary,代码行数:12,代码来源:libimg.py
示例15: setUp
def setUp(self):
# This multipage TIF file was created with imagemagick:
# convert im1.tif im2.tif -adjoin multipage.tif
use_plugin('pil')
paths = [os.path.join(data_dir, 'multipage_rgb.tif'),
os.path.join(data_dir, 'no_time_for_that_tiny.gif')]
self.imgs = [MultiImage(paths[0]),
MultiImage(paths[0], conserve_memory=False),
MultiImage(paths[1]),
MultiImage(paths[1], conserve_memory=False),
ImageCollection(paths[0]),
ImageCollection(paths[1], conserve_memory=False),
ImageCollection(os.pathsep.join(paths))]
开发者ID:andreydung,项目名称:scikit-image,代码行数:13,代码来源:test_multi_image.py
示例16: generate_reconstruction_mask
def generate_reconstruction_mask(out_fpaths, xdim, ydim, rcells, start_z, end_z):
"""Generate reconstruction mask."""
use_plugin('freeimage')
das = {z: np.zeros((xdim, ydim, 3), dtype=np.uint8)
for z in range(start_z, end_z+1)} # Plus one is intentional; end goes to z-1
for rcell in rcells:
c = shades_of_jop_unique()
for z, cellslice in rcell.slice_dict.items():
das[z][cellslice.coord_list] = c
for out_fn, z in zip(out_fpaths, range(start_z, end_z+1)):
# out_fn = os.path.join(out_dir, "da%d.tif" % z)
imsave(out_fn, das[z])
开发者ID:JIC-CSB,项目名称:root-image-analysis,代码行数:15,代码来源:reconstruct_and_measure.py
示例17: use_plugin
import os.path
import numpy as np
from numpy.testing.decorators import skipif
from tempfile import NamedTemporaryFile
from skimage import data_dir
from skimage.io import imread, imsave, use_plugin, reset_plugins
try:
import SimpleITK as sitk
use_plugin('simpleitk')
except ImportError:
sitk_available = False
else:
sitk_available = True
def teardown():
reset_plugins()
def setup_module(self):
"""The effect of the `plugin.use` call may be overridden by later imports.
Call `use_plugin` directly before the tests to ensure that sitk is used.
"""
try:
use_plugin('simpleitk')
except ImportError:
pass
开发者ID:A-0-,项目名称:scikit-image,代码行数:31,代码来源:test_simpleitk.py
示例18: in
import collections
import math
import numpy
from pathlib import Path
import scipy.ndimage
import scipy.ndimage.morphology
import skimage.exposure
import skimage.filters
import skimage.measure
import skimage.morphology
import skimage.io as skio
import sklearn.linear_model
import sklearn.neighbors
import sklearn.svm
for function in ('imread', 'imsave', 'imread_collection'):
skio.use_plugin('freeimage', function)
import multiprocessing
import os
import pickle
import sys
supplementary_out_exclusion_mask = skio.imread(str(Path(os.path.expanduser('~')) / 'Data' / 'experiment01_a' / 'supplementary_out_exclusion_mask.png'))
def select_random_in_mask_and_out_mask_coords(mask_fpath, coord_count, separation=None):
im_mask = skio.imread(str(mask_fpath)) > 0
labels = skimage.measure.label(im_mask)
regions = skimage.measure.regionprops(labels)
if len(regions) == 0:
raise RuntimeError('No regions found in mask image file "{}".'.format(str(mask_fpath)))
# Lump together the coordinates of every lit mask pixel
开发者ID:erikhvatum,项目名称:wautofocuser,代码行数:31,代码来源:make_experiment_01_a_dataset.py
示例19: setup
def setup():
use_plugin('pil')
开发者ID:haohao200609,项目名称:Hybrid,代码行数:2,代码来源:test_pil.py
示例20: generate_color_map
from skimage import img_as_float
from skimage import color
from skimage import io
import numpy as np
from skimage.feature import peak_local_max, corner_peaks
__author__ = "Kern"
io.use_plugin("matplotlib")
def generate_color_map(image, color_mask):
img_f = img_as_float(image)
black_mask = color.rgb2gray(img_f) < 0.1
distance = color.rgb2gray(1 - np.abs(img_f - color_mask))
distance[black_mask] = 0
return distance
def generate_red_map(image):
return generate_color_map(image, (1, 0, 0))
def generate_green_map(image):
return generate_color_map(image, (0, 1, 0))
def generate_pink_map(image):
return generate_color_map(image, (1, 0.5, 0.5))
开发者ID:erdincay,项目名称:ScoreGrass,代码行数:29,代码来源:PeakDetector.py
注:本文中的skimage.io.use_plugin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论