geowatch.tasks.depth.predict module¶
- geowatch.tasks.depth.predict.run_inference(image, model, device=0)[source]¶
Example
>>> from geowatch.tasks.depth.predict import * # NOQA >>> import kwimage >>> import kwarray >>> src = kwimage.ensure_float01(kwimage.grab_test_image(dsize=(512, 512))) >>> src = kwimage.Polygon.random(rng=None).scale(src.shape[0]).fill(src.copy(), np.nan) >>> model = fake_model >>> image = src * 255 >>> device = 'cpu' >>> result = run_inference(image, model, device=device) >>> # xdoctest: +REQUIRES(--show) >>> import kwplot >>> kwplot.autompl() >>> kwplot.imshow(src, pnum=(1, 2, 1), doclf=True) >>> kwplot.imshow(result, pnum=(1, 2, 2))
- geowatch.tasks.depth.predict.anisotropic_diffusion(img, niter=1, kappa=50, gamma=0.1, voxelspacing=None, option=1)[source]¶
Edge-preserving, XD Anisotropic diffusion.
- Parameters:
img (array_like) – Input image (will be cast to numpy.float).
niter (integer) – Number of iterations.
kappa (integer) – Conduction coefficient, e.g. 20-100.
kappacontrols conduction as a function of the gradient. Ifkappais low small intensity gradients are able to block conduction and hence diffusion across steep edges. A large value reduces the influence of intensity gradients on conduction.gamma (float) – Controls the speed of diffusion. Pick a value \(<= .25\) for stability.
voxelspacing (tuple of floats or array_like) – The distance between adjacent pixels in all img.ndim directions
option ({1, 2, 3}) – Whether to use the Perona Malik diffusion equation No. 1 or No. 2, or Tukey’s biweight function. Equation 1 favours high contrast edges over low contrast ones, while equation 2 favours wide regions over smaller ones. See [1] for details. Equation 3 preserves sharper boundaries than previous formulations and improves the automatic stopping of the diffusion. See [2] for details.
- Returns:
anisotropic_diffusion – Diffused image.
- Return type:
ndarray
Notes
Original MATLAB code by Peter Kovesi, School of Computer Science & Software Engineering, The University of Western Australia, pk @ csse uwa edu au, <http://www.csse.uwa.edu.au>
Translated to Python and optimised by Alistair Muldal, Department of Pharmacology, University of Oxford, <alistair.muldal@pharm.ox.ac.uk>
Adapted to arbitrary dimensionality and added to the MedPy library Oskar Maier, Institute for Medical Informatics, Universitaet Luebeck, <oskar.maier@googlemail.com>
June 2000 original version. - March 2002 corrected diffusion eqn No 2. - July 2012 translated to Python - August 2013 incorporated into MedPy, arbitrary dimensionality -
References