mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 21:08:24 +08:00
Merge pull request #1324 from ahojnnes/rel-import
Use relative imports in skimage files
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@ Build Requirements
|
||||
------------------
|
||||
* `Python >= 2.6 <http://python.org>`__
|
||||
* `Numpy >= 1.6 <http://numpy.scipy.org/>`__
|
||||
* `Cython >= 0.19.2 <http://www.cython.org/>`__
|
||||
* `Cython >= 0.21 <http://www.cython.org/>`__
|
||||
* `Six >=1.3 <https://pypi.python.org/pypi/six>`__
|
||||
|
||||
You can use pip to automatically install the base dependencies as follows::
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
cython>=0.19.2
|
||||
cython>=0.21
|
||||
matplotlib>=1.1.0
|
||||
numpy>=1.6.1
|
||||
scipy>=0.9
|
||||
|
||||
@@ -5,13 +5,13 @@ import os
|
||||
import re
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from skimage import (
|
||||
data, io, img_as_uint, img_as_float, img_as_int, img_as_ubyte)
|
||||
from numpy import testing
|
||||
import numpy as np
|
||||
from skimage._shared._warnings import expected_warnings
|
||||
import warnings
|
||||
|
||||
from .. import data, io, img_as_uint, img_as_float, img_as_int, img_as_ubyte
|
||||
|
||||
|
||||
SKIP_RE = re.compile("(\s*>>>.*?)(\s*)#\s*skip\s+if\s+(.*)$")
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import functools
|
||||
|
||||
import numpy as np
|
||||
|
||||
from skimage import color
|
||||
from skimage.util.dtype import convert
|
||||
from .. import color
|
||||
from ..util.dtype import convert
|
||||
|
||||
|
||||
__all__ = ['adapt_rgb', 'hsv_value', 'each_channel']
|
||||
|
||||
@@ -3,9 +3,9 @@ import itertools
|
||||
|
||||
import numpy as np
|
||||
|
||||
from skimage import img_as_float
|
||||
from .colorconv import rgb2gray, gray2rgb
|
||||
from .. import img_as_float
|
||||
from . import rgb_colors
|
||||
from .colorconv import rgb2gray, gray2rgb
|
||||
|
||||
import six
|
||||
from six.moves import zip
|
||||
|
||||
@@ -21,7 +21,7 @@ from __future__ import division
|
||||
|
||||
import numpy as np
|
||||
|
||||
from skimage.color.colorconv import lab2lch, _cart2polar_2pi
|
||||
from ..color.colorconv import lab2lch, _cart2polar_2pi
|
||||
|
||||
|
||||
def deltaE_cie76(lab1, lab2):
|
||||
|
||||
@@ -8,8 +8,8 @@ For more images, see
|
||||
|
||||
import os as _os
|
||||
|
||||
from .. import data_dir
|
||||
from ..io import imread, use_plugin
|
||||
from skimage import data_dir
|
||||
|
||||
|
||||
__all__ = ['load',
|
||||
|
||||
@@ -7,7 +7,7 @@ import numpy as np
|
||||
|
||||
cimport numpy as cnp
|
||||
from libc.math cimport sqrt, sin, cos, floor, ceil
|
||||
from skimage._shared.geometry cimport point_in_polygon
|
||||
from .._shared.geometry cimport point_in_polygon
|
||||
|
||||
|
||||
def _coords_inside_image(rr, cc, shape, val=None):
|
||||
|
||||
@@ -14,10 +14,10 @@ responsible. Basically, don't be a jerk, and remember that anything free
|
||||
comes with no guarantee.
|
||||
"""
|
||||
import numpy as np
|
||||
import skimage
|
||||
from skimage.color.adapt_rgb import adapt_rgb, hsv_value
|
||||
from skimage.exposure import rescale_intensity
|
||||
from skimage.util import view_as_blocks, pad
|
||||
from .. import img_as_float, img_as_uint
|
||||
from ..color.adapt_rgb import adapt_rgb, hsv_value
|
||||
from ..exposure import rescale_intensity
|
||||
from ..util import view_as_blocks, pad
|
||||
|
||||
|
||||
MAX_REG_X = 16 # max. # contextual regions in x-direction */
|
||||
@@ -74,11 +74,11 @@ def equalize_adapthist(image, ntiles_x=8, ntiles_y=8, clip_limit=0.01,
|
||||
.. [1] http://tog.acm.org/resources/GraphicsGems/gems.html#gemsvi
|
||||
.. [2] https://en.wikipedia.org/wiki/CLAHE#CLAHE
|
||||
"""
|
||||
image = skimage.img_as_uint(image)
|
||||
image = img_as_uint(image)
|
||||
image = rescale_intensity(image, out_range=(0, NR_OF_GREY - 1))
|
||||
out = _clahe(image, ntiles_x, ntiles_y, clip_limit * nbins, nbins)
|
||||
image[:out.shape[0], :out.shape[1]] = out
|
||||
image = skimage.img_as_float(image)
|
||||
image = img_as_float(image)
|
||||
return rescale_intensity(image)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import warnings
|
||||
import numpy as np
|
||||
|
||||
from skimage import img_as_float
|
||||
from skimage.util.dtype import dtype_range, dtype_limits
|
||||
from .. import img_as_float
|
||||
from ..util.dtype import dtype_range, dtype_limits
|
||||
|
||||
|
||||
__all__ = ['histogram', 'cumulative_distribution', 'equalize_hist',
|
||||
|
||||
@@ -16,8 +16,8 @@ import numpy as np
|
||||
import scipy.ndimage as ndi
|
||||
from scipy.ndimage import (gaussian_filter,
|
||||
generate_binary_structure, binary_erosion, label)
|
||||
from skimage import dtype_limits
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .. import dtype_limits
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
def smooth_with_function_and_mask(image, function, mask):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import numpy as np
|
||||
from scipy import sqrt, pi, arctan2, cos, sin, exp
|
||||
from scipy.ndimage import gaussian_filter
|
||||
import skimage.color
|
||||
from skimage import img_as_float, draw
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .. import img_as_float, draw
|
||||
from ..color import gray2rgb
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
def daisy(img, step=4, radius=15, rings=3, histograms=8, orientations=8,
|
||||
@@ -177,7 +177,7 @@ def daisy(img, step=4, radius=15, rings=3, histograms=8, orientations=8,
|
||||
descs[:, :, i:i + orientations] /= norms[:, :, np.newaxis]
|
||||
|
||||
if visualize:
|
||||
descs_img = skimage.color.gray2rgb(img)
|
||||
descs_img = gray2rgb(img)
|
||||
for i in range(descs.shape[0]):
|
||||
for j in range(descs.shape[1]):
|
||||
# Draw center histogram sigma
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
from scipy import sqrt, pi, arctan2, cos, sin
|
||||
from scipy.ndimage import uniform_filter
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
@@ -137,7 +137,7 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
hog_image = None
|
||||
|
||||
if visualise:
|
||||
from skimage import draw
|
||||
from .. import draw
|
||||
|
||||
radius = min(cx, cy) // 2 - 1
|
||||
hog_image = np.zeros((sy, sx), dtype=float)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import numpy as np
|
||||
cimport numpy as cnp
|
||||
from libc.math cimport sin, cos, abs
|
||||
from skimage._shared.interpolation cimport bilinear_interpolation, round
|
||||
from .._shared.interpolation cimport bilinear_interpolation, round
|
||||
|
||||
|
||||
def _glcm_loop(cnp.uint8_t[:, ::1] image, double[:] distances,
|
||||
|
||||
@@ -5,11 +5,11 @@ import itertools as itt
|
||||
import math
|
||||
from math import sqrt, hypot, log
|
||||
from numpy import arccos
|
||||
from skimage.util import img_as_float
|
||||
from ..util import img_as_float
|
||||
from .peak import peak_local_max
|
||||
from ._hessian_det_appx import _hessian_matrix_det
|
||||
from skimage.transform import integral_image
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..transform import integral_image
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
# This basic blob detection algorithm is based on:
|
||||
|
||||
@@ -5,7 +5,7 @@ from .util import (DescriptorExtractor, _mask_border_keypoints,
|
||||
_prepare_grayscale_input_2D)
|
||||
|
||||
from .brief_cy import _brief_loop
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
class BRIEF(DescriptorExtractor):
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import numpy as np
|
||||
from scipy.ndimage.filters import maximum_filter, minimum_filter, convolve
|
||||
|
||||
from skimage.feature.util import FeatureDetector, _prepare_grayscale_input_2D
|
||||
|
||||
from skimage.transform import integral_image
|
||||
from skimage.feature import structure_tensor
|
||||
from skimage.morphology import octagon, star
|
||||
from skimage.feature.util import _mask_border_keypoints
|
||||
|
||||
from skimage.feature.censure_cy import _censure_dob_loop
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..transform import integral_image
|
||||
from ..feature import structure_tensor
|
||||
from ..morphology import octagon, star
|
||||
from ..feature.censure_cy import _censure_dob_loop
|
||||
from ..feature.util import (FeatureDetector, _prepare_grayscale_input_2D,
|
||||
_mask_border_keypoints)
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
# The paper(Reference [1]) mentions the sizes of the Octagon shaped filter
|
||||
# kernel for the first seven scales only. The sizes of the later scales
|
||||
|
||||
@@ -2,10 +2,10 @@ import numpy as np
|
||||
from scipy import ndimage
|
||||
from scipy import stats
|
||||
|
||||
from skimage.util import img_as_float, pad
|
||||
from skimage.feature import peak_local_max
|
||||
from skimage.feature.util import _prepare_grayscale_input_2D
|
||||
from skimage.feature.corner_cy import _corner_fast
|
||||
from ..util import img_as_float, pad
|
||||
from ..feature import peak_local_max
|
||||
from ..feature.util import _prepare_grayscale_input_2D
|
||||
from ..feature.corner_cy import _corner_fast
|
||||
from ._hessian_det_appx import _hessian_matrix_det
|
||||
from ..transform import integral_image
|
||||
from .._shared.utils import safe_as_int
|
||||
|
||||
@@ -7,8 +7,8 @@ cimport numpy as cnp
|
||||
from libc.float cimport DBL_MAX
|
||||
from libc.math cimport atan2
|
||||
|
||||
from skimage.util import img_as_float, pad
|
||||
from skimage.color import rgb2grey
|
||||
from ..util import img_as_float, pad
|
||||
from ..color import rgb2grey
|
||||
|
||||
from .util import _prepare_grayscale_input_2D
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import numpy as np
|
||||
|
||||
from skimage.feature.util import (FeatureDetector, DescriptorExtractor,
|
||||
_mask_border_keypoints,
|
||||
_prepare_grayscale_input_2D)
|
||||
from ..feature.util import (FeatureDetector, DescriptorExtractor,
|
||||
_mask_border_keypoints,
|
||||
_prepare_grayscale_input_2D)
|
||||
|
||||
from skimage.feature import (corner_fast, corner_orientations, corner_peaks,
|
||||
from ..feature import (corner_fast, corner_orientations, corner_peaks,
|
||||
corner_harris)
|
||||
from skimage.transform import pyramid_gaussian
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..transform import pyramid_gaussian
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
from .orb_cy import _orb_loop
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
from skimage import data_dir
|
||||
from .. import data_dir
|
||||
|
||||
cimport numpy as cnp
|
||||
from libc.math cimport sin, cos
|
||||
|
||||
from skimage._shared.interpolation cimport round
|
||||
from .._shared.interpolation cimport round
|
||||
|
||||
POS = np.loadtxt(os.path.join(data_dir, "orb_descriptor_positions.txt"),
|
||||
dtype=np.int8)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import numpy as np
|
||||
from scipy.signal import fftconvolve
|
||||
|
||||
from skimage.util import pad
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..util import pad
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
def _window_sum_2d(image, window_shape):
|
||||
|
||||
@@ -3,7 +3,7 @@ Methods to characterize image textures.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .._shared.utils import assert_nD
|
||||
from ._texture import _glcm_loop, _local_binary_pattern
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from skimage.util import img_as_float
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..util import img_as_float
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
class FeatureDetector(object):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from skimage._shared.utils import skimage_deprecation
|
||||
from .._shared.utils import skimage_deprecation
|
||||
from warnings import warn
|
||||
|
||||
global _import_warned
|
||||
|
||||
@@ -13,8 +13,8 @@ from .thresholding import (threshold_adaptive, threshold_otsu, threshold_yen,
|
||||
from . import rank
|
||||
from .rank import median
|
||||
|
||||
from skimage._shared.utils import deprecated
|
||||
from skimage import restoration
|
||||
from .._shared.utils import deprecated
|
||||
from .. import restoration
|
||||
denoise_bilateral = deprecated('skimage.restoration.denoise_bilateral')\
|
||||
(restoration.denoise_bilateral)
|
||||
denoise_tv_bregman = deprecated('skimage.restoration.denoise_tv_bregman')\
|
||||
@@ -26,7 +26,7 @@ denoise_tv_chambolle = deprecated('skimage.restoration.denoise_tv_chambolle')\
|
||||
@deprecated
|
||||
def canny(*args, **kwargs):
|
||||
# Hack to avoid circular import
|
||||
from skimage.feature._canny import canny as canny_
|
||||
from ..feature._canny import canny as canny_
|
||||
return canny_(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
__all__ = ['gabor_kernel', 'gabor_filter']
|
||||
|
||||
@@ -10,8 +10,8 @@ Original author: Lee Kamentsky
|
||||
|
||||
"""
|
||||
import numpy as np
|
||||
from skimage import img_as_float
|
||||
from skimage._shared.utils import assert_nD, deprecated
|
||||
from .. import img_as_float
|
||||
from .._shared.utils import assert_nD, deprecated
|
||||
from scipy.ndimage import convolve, binary_erosion, generate_binary_structure
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import numpy as np
|
||||
from scipy.fftpack import ifftshift
|
||||
from skimage._shared.utils import assert_nD
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
eps = np.finfo(float).eps
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ References
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..._shared.utils import assert_nD
|
||||
|
||||
from . import percentile_cy
|
||||
from .generic import _handle_input
|
||||
|
||||
@@ -24,8 +24,8 @@ References
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from skimage import img_as_ubyte
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ... import img_as_ubyte
|
||||
from ..._shared.utils import assert_nD
|
||||
|
||||
from . import bilateral_cy
|
||||
from .generic import _handle_input
|
||||
|
||||
@@ -18,8 +18,8 @@ References
|
||||
|
||||
import warnings
|
||||
import numpy as np
|
||||
from skimage import img_as_ubyte
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ... import img_as_ubyte
|
||||
from ..._shared.utils import assert_nD
|
||||
|
||||
from . import generic_cy
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ __all__ = ['threshold_adaptive',
|
||||
|
||||
import numpy as np
|
||||
import scipy.ndimage
|
||||
from skimage.exposure import histogram
|
||||
from skimage._shared.utils import assert_nD
|
||||
from ..exposure import histogram
|
||||
from .._shared.utils import assert_nD
|
||||
|
||||
|
||||
def threshold_adaptive(image, block_size, method='gaussian', offset=0,
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ from io import BytesIO
|
||||
import numpy as np
|
||||
import six
|
||||
|
||||
from skimage.io.manage_plugins import call_plugin
|
||||
from skimage.color import rgb2grey
|
||||
from ..io.manage_plugins import call_plugin
|
||||
from ..color import rgb2grey
|
||||
from .util import file_or_url_context
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
__all__ = ['imread', 'imsave']
|
||||
|
||||
from skimage.util.dtype import convert
|
||||
from ...util.dtype import convert
|
||||
|
||||
try:
|
||||
import imread as _imread
|
||||
@@ -33,7 +33,7 @@ def imsave(fname, arr, format_str=None):
|
||||
arr : ndarray of uint8 or uint16
|
||||
Array (image) to save.
|
||||
format_str: str,optional
|
||||
Format to save as.
|
||||
Format to save as.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
@@ -4,9 +4,8 @@ import numpy as np
|
||||
from six import string_types
|
||||
from PIL import Image
|
||||
|
||||
from skimage.util import img_as_ubyte, img_as_uint
|
||||
from skimage.external.tifffile import (
|
||||
imread as tif_imread, imsave as tif_imsave)
|
||||
from ...util import img_as_ubyte, img_as_uint
|
||||
from ...external.tifffile import imread as tif_imread, imsave as tif_imsave
|
||||
|
||||
|
||||
def imread(fname, dtype=None, img_num=None, **kwargs):
|
||||
|
||||
@@ -209,7 +209,7 @@ class SkiviImageWindow(QMainWindow):
|
||||
self.rgb_hsv_disp.update_vals((x, y, r, g, b, h, s, v))
|
||||
|
||||
def save_to_stack(self):
|
||||
from skimage import io
|
||||
from ... import io
|
||||
img = self.arr.copy()
|
||||
io.push(img)
|
||||
msg = dedent('''
|
||||
@@ -227,7 +227,7 @@ class SkiviImageWindow(QMainWindow):
|
||||
dialog.exec_()
|
||||
|
||||
def save_to_file(self):
|
||||
from skimage import io
|
||||
from ... import io
|
||||
filename = str(QtGui.QFileDialog.getSaveFileName())
|
||||
if len(filename) == 0:
|
||||
return
|
||||
|
||||
@@ -1 +1 @@
|
||||
from skimage.external.tifffile import imread, imsave
|
||||
from ...external.tifffile import imread, imsave
|
||||
|
||||
@@ -2,7 +2,7 @@ import numpy as np
|
||||
from . import _colormixer
|
||||
from . import _histograms
|
||||
import threading
|
||||
from skimage.util import img_as_ubyte
|
||||
from ...util import img_as_ubyte
|
||||
|
||||
# utilities to make life easier for plugin writers.
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import numpy as np
|
||||
import six
|
||||
from PIL import Image
|
||||
|
||||
from skimage.external.tifffile import TiffFile
|
||||
from ..external.tifffile import TiffFile
|
||||
|
||||
|
||||
__all__ = ['MultiImage', 'ImageCollection', 'concatenate_images',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import numpy as np
|
||||
|
||||
cimport numpy as cnp
|
||||
from skimage._shared.geometry cimport point_in_polygon, points_in_polygon
|
||||
from .._shared.geometry cimport point_in_polygon, points_in_polygon
|
||||
|
||||
|
||||
def grid_points_in_poly(shape, verts):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from skimage.util import view_as_blocks, pad
|
||||
from ..util import view_as_blocks, pad
|
||||
|
||||
|
||||
def block_reduce(image, block_size, func=np.sum, cval=0):
|
||||
|
||||
@@ -11,7 +11,7 @@ from .greyreconstruct import reconstruction
|
||||
from .misc import remove_small_objects
|
||||
|
||||
from ..measure._label import label
|
||||
from skimage._shared.utils import deprecated as _deprecated
|
||||
from .._shared.utils import deprecated as _deprecated
|
||||
label = _deprecated('skimage.measure.label')(label)
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ Original author: Lee Kamentsky
|
||||
'''
|
||||
|
||||
import numpy as np
|
||||
|
||||
cimport numpy as cnp
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import numpy as np
|
||||
from ..measure import grid_points_in_poly
|
||||
from ._convex_hull import possible_hull
|
||||
from ..measure._label import label
|
||||
from skimage.util import unique_rows
|
||||
from ..util import unique_rows
|
||||
|
||||
|
||||
def convex_hull_image(image):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
Grayscale morphological operations
|
||||
"""
|
||||
import functools
|
||||
|
||||
import numpy as np
|
||||
from scipy import ndimage as nd
|
||||
from .misc import default_selem
|
||||
|
||||
@@ -11,7 +11,7 @@ Original author: Lee Kamentsky
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from skimage.filters._rank_order import rank_order
|
||||
from ..filters._rank_order import rank_order
|
||||
|
||||
|
||||
def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from skimage import draw
|
||||
from .. import draw
|
||||
|
||||
def square(width, dtype=np.uint8):
|
||||
"""Generates a flat, square-shaped structuring element.
|
||||
|
||||
@@ -4,11 +4,10 @@ from collections import namedtuple
|
||||
from io import BytesIO
|
||||
|
||||
import numpy as np
|
||||
from skimage import io
|
||||
from skimage import img_as_ubyte
|
||||
from skimage.transform import resize
|
||||
from skimage.color import color_dict
|
||||
from skimage.io.util import file_or_url_context, is_url
|
||||
from .. import io, img_as_ubyte
|
||||
from ..transform import resize
|
||||
from ..color import color_dict
|
||||
from ..io.util import file_or_url_context, is_url
|
||||
|
||||
import six
|
||||
from six.moves.urllib_parse import urlparse
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# coding: utf-8
|
||||
import numpy as np
|
||||
from skimage import img_as_float
|
||||
from skimage.restoration._denoise_cy import (_denoise_bilateral,
|
||||
_denoise_tv_bregman)
|
||||
from .. import img_as_float
|
||||
from ..restoration._denoise_cy import _denoise_bilateral, _denoise_tv_bregman
|
||||
|
||||
|
||||
def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
|
||||
|
||||
@@ -8,8 +8,8 @@ import numpy as np
|
||||
from libc.math cimport exp, fabs, sqrt
|
||||
from libc.stdlib cimport malloc, free
|
||||
from libc.float cimport DBL_MAX
|
||||
from skimage._shared.interpolation cimport get_pixel3d
|
||||
from skimage.util import img_as_float
|
||||
from .._shared.interpolation cimport get_pixel3d
|
||||
from ..util import img_as_float
|
||||
|
||||
|
||||
cdef inline double _gaussian_weight(double sigma, double value):
|
||||
|
||||
@@ -7,7 +7,7 @@ import scipy
|
||||
|
||||
cimport cython
|
||||
cimport numpy as cnp
|
||||
from skimage.measure._ccomp cimport find_root, join_trees
|
||||
from ..measure._ccomp cimport find_root, join_trees
|
||||
|
||||
from ..util import img_as_float
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from skimage._shared.utils import deprecated
|
||||
from .._shared.utils import deprecated
|
||||
|
||||
|
||||
def join_segmentations(s1, s2):
|
||||
|
||||
@@ -8,7 +8,7 @@ from cpython cimport bool
|
||||
import numpy as np
|
||||
cimport numpy as cnp
|
||||
|
||||
from skimage.util import regular_grid
|
||||
from ..util import regular_grid
|
||||
|
||||
|
||||
def _slic_cython(double[:, :, :, ::1] image_zyx,
|
||||
@@ -32,7 +32,7 @@ def _slic_cython(double[:, :, :, ::1] image_zyx,
|
||||
spacing : 1D array of double, shape (3,)
|
||||
The voxel spacing along each image dimension. This parameter
|
||||
controls the weights of the distances along z, y, and x during
|
||||
k-means clustering.
|
||||
k-means clustering.
|
||||
slic_zero : bool
|
||||
True to run SLIC-zero, False to run original SLIC.
|
||||
|
||||
@@ -178,7 +178,7 @@ def _slic_cython(double[:, :, :, ::1] image_zyx,
|
||||
for c in range(3, n_features):
|
||||
dist_color += (image_zyx[z, y, x, c - 3] -
|
||||
segments[k, c]) ** 2
|
||||
|
||||
|
||||
# The reference implementation seems to only change
|
||||
# the color if it increases from previous iteration
|
||||
if max_dist_color[k] < dist_color:
|
||||
|
||||
@@ -5,10 +5,10 @@ import numpy as np
|
||||
from scipy import ndimage
|
||||
import warnings
|
||||
|
||||
from skimage.util import img_as_float, regular_grid
|
||||
from skimage.segmentation._slic import (_slic_cython,
|
||||
_enforce_label_connectivity_cython)
|
||||
from skimage.color import rgb2lab
|
||||
from ..util import img_as_float, regular_grid
|
||||
from ..segmentation._slic import (_slic_cython,
|
||||
_enforce_label_connectivity_cython)
|
||||
from ..color import rgb2lab
|
||||
|
||||
|
||||
def slic(image, n_segments=100, compactness=10., max_iter=10, sigma=0,
|
||||
|
||||
@@ -10,12 +10,12 @@ cimport cython
|
||||
from libc.math cimport abs, fabs, sqrt, ceil, atan2, M_PI
|
||||
from libc.stdlib cimport rand
|
||||
|
||||
from skimage.draw import circle_perimeter
|
||||
from ..draw import circle_perimeter
|
||||
|
||||
cdef double PI_2 = 1.5707963267948966
|
||||
cdef double NEG_PI_2 = -PI_2
|
||||
|
||||
from skimage._shared.interpolation cimport round
|
||||
from .._shared.interpolation cimport round
|
||||
|
||||
|
||||
def _hough_circle(cnp.ndarray img,
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#cython: wraparound=False
|
||||
import numpy as np
|
||||
cimport numpy as cnp
|
||||
from skimage._shared.interpolation cimport (nearest_neighbour_interpolation,
|
||||
bilinear_interpolation,
|
||||
biquadratic_interpolation,
|
||||
bicubic_interpolation)
|
||||
from .._shared.interpolation cimport (nearest_neighbour_interpolation,
|
||||
bilinear_interpolation,
|
||||
biquadratic_interpolation,
|
||||
bicubic_interpolation)
|
||||
|
||||
|
||||
cdef inline void _matrix_transform(double x, double y, double* H, double *x_,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from skimage import measure, morphology
|
||||
from .. import measure, morphology
|
||||
from ._hough_transform import _hough_circle
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import math
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from skimage.transform import resize
|
||||
from skimage.util import img_as_float
|
||||
from ..transform import resize
|
||||
from ..util import img_as_float
|
||||
|
||||
|
||||
def _smooth(image, sigma, mode, cval):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
from matplotlib import lines
|
||||
from skimage.viewer.canvastools.base import CanvasToolBase, ToolHandles
|
||||
from ...viewer.canvastools.base import CanvasToolBase, ToolHandles
|
||||
|
||||
|
||||
__all__ = ['LineTool', 'ThickLineTool']
|
||||
@@ -200,8 +199,8 @@ class ThickLineTool(LineTool):
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
from skimage import data
|
||||
from skimage.viewer import ImageViewer
|
||||
from ... import data
|
||||
from ...viewer import ImageViewer
|
||||
|
||||
image = data.camera()
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
|
||||
import matplotlib.colors as mcolors
|
||||
LABELS_CMAP = mcolors.ListedColormap(['white', 'red', 'dodgerblue', 'gold',
|
||||
'greenyellow', 'blueviolet'])
|
||||
from skimage.viewer.canvastools.base import CanvasToolBase
|
||||
from ...viewer.canvastools.base import CanvasToolBase
|
||||
|
||||
|
||||
__all__ = ['PaintTool']
|
||||
@@ -198,8 +198,8 @@ class CenteredWindow(object):
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
np.testing.rundocs()
|
||||
from skimage import data
|
||||
from skimage.viewer import ImageViewer
|
||||
from ... import data
|
||||
from ...viewer import ImageViewer
|
||||
|
||||
image = data.camera()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from matplotlib.widgets import RectangleSelector
|
||||
from skimage.viewer.canvastools.base import CanvasToolBase
|
||||
from skimage.viewer.canvastools.base import ToolHandles
|
||||
from ...viewer.canvastools.base import CanvasToolBase
|
||||
from ...viewer.canvastools.base import ToolHandles
|
||||
|
||||
|
||||
__all__ = ['RectangleTool']
|
||||
@@ -33,7 +33,7 @@ class RectangleTool(CanvasToolBase, RectangleSelector):
|
||||
----------
|
||||
extents : tuple
|
||||
Rectangle extents: (xmin, xmax, ymin, ymax).
|
||||
|
||||
|
||||
Examples
|
||||
----------
|
||||
>>> from skimage import data
|
||||
@@ -41,12 +41,12 @@ class RectangleTool(CanvasToolBase, RectangleSelector):
|
||||
>>> from skimage.viewer.canvastools import RectangleTool
|
||||
>>> from skimage.draw import line
|
||||
>>> from skimage.draw import set_color
|
||||
|
||||
|
||||
>>> viewer = ImageViewer(data.coffee()) # doctest: +SKIP
|
||||
|
||||
>>> def print_the_rect(extents):
|
||||
... global viewer
|
||||
... im = viewer.image
|
||||
... im = viewer.image
|
||||
... coord = np.int64(extents)
|
||||
... [rr1, cc1] = line(coord[2],coord[0],coord[2],coord[1])
|
||||
... [rr2, cc2] = line(coord[2],coord[1],coord[3],coord[1])
|
||||
@@ -57,11 +57,11 @@ class RectangleTool(CanvasToolBase, RectangleSelector):
|
||||
... set_color(im, (rr3, cc3), [255, 0, 255])
|
||||
... set_color(im, (rr4, cc4), [0, 0, 0])
|
||||
... viewer.image=im
|
||||
|
||||
|
||||
>>> rect_tool = RectangleTool(viewer.ax, on_enter=print_the_rect) # doctest: +SKIP
|
||||
>>> viewer.show() # doctest: +SKIP
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, viewer, on_move=None, on_release=None, on_enter=None,
|
||||
maxdist=10, rect_props=None):
|
||||
self._rect = None
|
||||
@@ -234,8 +234,8 @@ class RectangleTool(CanvasToolBase, RectangleSelector):
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
from skimage.viewer import ImageViewer
|
||||
from skimage import data
|
||||
from ...viewer import ImageViewer
|
||||
from ... import data
|
||||
|
||||
viewer = ImageViewer(data.camera())
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
import skimage
|
||||
from skimage.feature import canny
|
||||
from ...feature import canny
|
||||
from .overlayplugin import OverlayPlugin
|
||||
from ..widgets import Slider, ComboBox
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from skimage import color
|
||||
from skimage import exposure
|
||||
from ... import color, exposure
|
||||
from .plotplugin import PlotPlugin
|
||||
from ..canvastools import RectangleTool
|
||||
|
||||
@@ -92,4 +91,3 @@ def pct_total_area(image, percentile=0.80):
|
||||
idx = int((image.size - 1) * percentile)
|
||||
sorted_pixels = np.sort(image.flat)
|
||||
return sorted_pixels[idx]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from .base import Plugin
|
||||
from ..canvastools import RectangleTool
|
||||
from skimage.viewer.widgets import SaveButtons
|
||||
from ...viewer.widgets import SaveButtons
|
||||
|
||||
|
||||
__all__ = ['Crop']
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from __future__ import division
|
||||
|
||||
import numpy as np
|
||||
from skimage.util.dtype import dtype_range
|
||||
from skimage import draw
|
||||
from skimage import measure
|
||||
from ...util.dtype import dtype_range
|
||||
from ... import draw, measure
|
||||
|
||||
from .plotplugin import PlotPlugin
|
||||
from ..canvastools import ThickLineTool
|
||||
@@ -65,7 +64,7 @@ class LineProfile(PlotPlugin):
|
||||
on_change=self.line_changed)
|
||||
self.line_tool.end_points = np.transpose([x, y])
|
||||
|
||||
scan_data = measure.profile_line(image,
|
||||
scan_data = measure.profile_line(image,
|
||||
*self.line_tool.end_points[:, ::-1])
|
||||
self.scan_data = scan_data
|
||||
if scan_data.ndim == 1:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from warnings import warn
|
||||
|
||||
from skimage.util.dtype import dtype_range
|
||||
from ...util.dtype import dtype_range
|
||||
from .base import Plugin
|
||||
from ..utils import ClearColormap, update_axes_image
|
||||
|
||||
import six
|
||||
from skimage._shared.version_requirements import is_installed
|
||||
from ..._shared.version_requirements import is_installed
|
||||
|
||||
|
||||
__all__ = ['OverlayPlugin']
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
ImageViewer class for viewing and interacting with images.
|
||||
"""
|
||||
|
||||
from skimage.viewer.qt import QtWidgets, Qt, Signal
|
||||
from skimage import io, img_as_float
|
||||
from skimage.util.dtype import dtype_range
|
||||
from skimage.exposure import rescale_intensity
|
||||
import numpy as np
|
||||
from ... import io, img_as_float
|
||||
from ...util.dtype import dtype_range
|
||||
from ...exposure import rescale_intensity
|
||||
from ..qt import QtWidgets, Qt, Signal
|
||||
from ..widgets import Slider
|
||||
from ..utils import (
|
||||
dialogs, init_qtapp, figimage, start_qtapp, update_axes_image)
|
||||
from ..utils import (dialogs, init_qtapp, figimage, start_qtapp,
|
||||
update_axes_image)
|
||||
from ..plugins.base import Plugin
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from ..qt import QtGui, QtCore
|
||||
import numpy as np
|
||||
|
||||
import skimage
|
||||
from skimage import io
|
||||
from ... import io, img_as_ubyte
|
||||
from .core import BaseWidget
|
||||
from ..utils import dialogs
|
||||
|
||||
@@ -87,7 +87,7 @@ class SaveButtons(BaseWidget):
|
||||
image = self.plugin.filtered_image
|
||||
if image.dtype == np.bool:
|
||||
#TODO: This check/conversion should probably be in `imsave`.
|
||||
image = skimage.img_as_ubyte(image)
|
||||
image = img_as_ubyte(image)
|
||||
io.imsave(filename, image)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user