scipy 1.16.2__cp314-cp314-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scipy/__config__.py +161 -0
- scipy/__init__.py +150 -0
- scipy/_cyutility.cp314-win_arm64.lib +0 -0
- scipy/_cyutility.cp314-win_arm64.pyd +0 -0
- scipy/_distributor_init.py +18 -0
- scipy/_lib/__init__.py +14 -0
- scipy/_lib/_array_api.py +931 -0
- scipy/_lib/_array_api_compat_vendor.py +9 -0
- scipy/_lib/_array_api_no_0d.py +103 -0
- scipy/_lib/_bunch.py +229 -0
- scipy/_lib/_ccallback.py +251 -0
- scipy/_lib/_ccallback_c.cp314-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_disjoint_set.py +254 -0
- scipy/_lib/_docscrape.py +761 -0
- scipy/_lib/_elementwise_iterative_method.py +346 -0
- scipy/_lib/_fpumode.cp314-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_gcutils.py +105 -0
- scipy/_lib/_pep440.py +487 -0
- scipy/_lib/_sparse.py +41 -0
- scipy/_lib/_test_ccallback.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_testutils.py +373 -0
- scipy/_lib/_threadsafety.py +58 -0
- scipy/_lib/_tmpdirs.py +86 -0
- scipy/_lib/_uarray/LICENSE +29 -0
- scipy/_lib/_uarray/__init__.py +116 -0
- scipy/_lib/_uarray/_backend.py +707 -0
- scipy/_lib/_uarray/_uarray.cp314-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_util.py +1283 -0
- scipy/_lib/array_api_compat/__init__.py +22 -0
- scipy/_lib/array_api_compat/_internal.py +59 -0
- scipy/_lib/array_api_compat/common/__init__.py +1 -0
- scipy/_lib/array_api_compat/common/_aliases.py +727 -0
- scipy/_lib/array_api_compat/common/_fft.py +213 -0
- scipy/_lib/array_api_compat/common/_helpers.py +1058 -0
- scipy/_lib/array_api_compat/common/_linalg.py +232 -0
- scipy/_lib/array_api_compat/common/_typing.py +192 -0
- scipy/_lib/array_api_compat/cupy/__init__.py +13 -0
- scipy/_lib/array_api_compat/cupy/_aliases.py +156 -0
- scipy/_lib/array_api_compat/cupy/_info.py +336 -0
- scipy/_lib/array_api_compat/cupy/_typing.py +31 -0
- scipy/_lib/array_api_compat/cupy/fft.py +36 -0
- scipy/_lib/array_api_compat/cupy/linalg.py +49 -0
- scipy/_lib/array_api_compat/dask/__init__.py +0 -0
- scipy/_lib/array_api_compat/dask/array/__init__.py +12 -0
- scipy/_lib/array_api_compat/dask/array/_aliases.py +376 -0
- scipy/_lib/array_api_compat/dask/array/_info.py +416 -0
- scipy/_lib/array_api_compat/dask/array/fft.py +21 -0
- scipy/_lib/array_api_compat/dask/array/linalg.py +72 -0
- scipy/_lib/array_api_compat/numpy/__init__.py +28 -0
- scipy/_lib/array_api_compat/numpy/_aliases.py +190 -0
- scipy/_lib/array_api_compat/numpy/_info.py +366 -0
- scipy/_lib/array_api_compat/numpy/_typing.py +30 -0
- scipy/_lib/array_api_compat/numpy/fft.py +35 -0
- scipy/_lib/array_api_compat/numpy/linalg.py +143 -0
- scipy/_lib/array_api_compat/torch/__init__.py +22 -0
- scipy/_lib/array_api_compat/torch/_aliases.py +855 -0
- scipy/_lib/array_api_compat/torch/_info.py +369 -0
- scipy/_lib/array_api_compat/torch/_typing.py +3 -0
- scipy/_lib/array_api_compat/torch/fft.py +85 -0
- scipy/_lib/array_api_compat/torch/linalg.py +121 -0
- scipy/_lib/array_api_extra/__init__.py +38 -0
- scipy/_lib/array_api_extra/_delegation.py +171 -0
- scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_at.py +463 -0
- scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
- scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
- scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
- scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
- scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
- scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
- scipy/_lib/array_api_extra/testing.py +359 -0
- scipy/_lib/cobyqa/__init__.py +20 -0
- scipy/_lib/cobyqa/framework.py +1240 -0
- scipy/_lib/cobyqa/main.py +1506 -0
- scipy/_lib/cobyqa/models.py +1529 -0
- scipy/_lib/cobyqa/problem.py +1296 -0
- scipy/_lib/cobyqa/settings.py +132 -0
- scipy/_lib/cobyqa/subsolvers/__init__.py +14 -0
- scipy/_lib/cobyqa/subsolvers/geometry.py +387 -0
- scipy/_lib/cobyqa/subsolvers/optim.py +1203 -0
- scipy/_lib/cobyqa/utils/__init__.py +18 -0
- scipy/_lib/cobyqa/utils/exceptions.py +22 -0
- scipy/_lib/cobyqa/utils/math.py +77 -0
- scipy/_lib/cobyqa/utils/versions.py +67 -0
- scipy/_lib/decorator.py +399 -0
- scipy/_lib/deprecation.py +274 -0
- scipy/_lib/doccer.py +366 -0
- scipy/_lib/messagestream.cp314-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp314-win_arm64.pyd +0 -0
- scipy/_lib/pyprima/__init__.py +212 -0
- scipy/_lib/pyprima/cobyla/__init__.py +0 -0
- scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
- scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
- scipy/_lib/pyprima/cobyla/geometry.py +226 -0
- scipy/_lib/pyprima/cobyla/initialize.py +215 -0
- scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
- scipy/_lib/pyprima/cobyla/update.py +289 -0
- scipy/_lib/pyprima/common/__init__.py +0 -0
- scipy/_lib/pyprima/common/_bounds.py +34 -0
- scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
- scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
- scipy/_lib/pyprima/common/_project.py +173 -0
- scipy/_lib/pyprima/common/checkbreak.py +93 -0
- scipy/_lib/pyprima/common/consts.py +47 -0
- scipy/_lib/pyprima/common/evaluate.py +99 -0
- scipy/_lib/pyprima/common/history.py +38 -0
- scipy/_lib/pyprima/common/infos.py +30 -0
- scipy/_lib/pyprima/common/linalg.py +435 -0
- scipy/_lib/pyprima/common/message.py +290 -0
- scipy/_lib/pyprima/common/powalg.py +131 -0
- scipy/_lib/pyprima/common/preproc.py +277 -0
- scipy/_lib/pyprima/common/present.py +5 -0
- scipy/_lib/pyprima/common/ratio.py +54 -0
- scipy/_lib/pyprima/common/redrho.py +47 -0
- scipy/_lib/pyprima/common/selectx.py +296 -0
- scipy/_lib/tests/__init__.py +0 -0
- scipy/_lib/tests/test__gcutils.py +110 -0
- scipy/_lib/tests/test__pep440.py +67 -0
- scipy/_lib/tests/test__testutils.py +32 -0
- scipy/_lib/tests/test__threadsafety.py +51 -0
- scipy/_lib/tests/test__util.py +641 -0
- scipy/_lib/tests/test_array_api.py +322 -0
- scipy/_lib/tests/test_bunch.py +169 -0
- scipy/_lib/tests/test_ccallback.py +196 -0
- scipy/_lib/tests/test_config.py +45 -0
- scipy/_lib/tests/test_deprecation.py +10 -0
- scipy/_lib/tests/test_doccer.py +143 -0
- scipy/_lib/tests/test_import_cycles.py +18 -0
- scipy/_lib/tests/test_public_api.py +482 -0
- scipy/_lib/tests/test_scipy_version.py +28 -0
- scipy/_lib/tests/test_tmpdirs.py +48 -0
- scipy/_lib/tests/test_warnings.py +137 -0
- scipy/_lib/uarray.py +31 -0
- scipy/cluster/__init__.py +31 -0
- scipy/cluster/_hierarchy.cp314-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp314-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp314-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp314-win_arm64.pyd +0 -0
- scipy/cluster/hierarchy.py +4348 -0
- scipy/cluster/tests/__init__.py +0 -0
- scipy/cluster/tests/hierarchy_test_data.py +145 -0
- scipy/cluster/tests/test_disjoint_set.py +202 -0
- scipy/cluster/tests/test_hierarchy.py +1238 -0
- scipy/cluster/tests/test_vq.py +434 -0
- scipy/cluster/vq.py +832 -0
- scipy/conftest.py +683 -0
- scipy/constants/__init__.py +358 -0
- scipy/constants/_codata.py +2266 -0
- scipy/constants/_constants.py +369 -0
- scipy/constants/codata.py +21 -0
- scipy/constants/constants.py +53 -0
- scipy/constants/tests/__init__.py +0 -0
- scipy/constants/tests/test_codata.py +78 -0
- scipy/constants/tests/test_constants.py +83 -0
- scipy/datasets/__init__.py +90 -0
- scipy/datasets/_download_all.py +71 -0
- scipy/datasets/_fetchers.py +225 -0
- scipy/datasets/_registry.py +26 -0
- scipy/datasets/_utils.py +81 -0
- scipy/datasets/tests/__init__.py +0 -0
- scipy/datasets/tests/test_data.py +128 -0
- scipy/differentiate/__init__.py +27 -0
- scipy/differentiate/_differentiate.py +1129 -0
- scipy/differentiate/tests/__init__.py +0 -0
- scipy/differentiate/tests/test_differentiate.py +694 -0
- scipy/fft/__init__.py +114 -0
- scipy/fft/_backend.py +196 -0
- scipy/fft/_basic.py +1650 -0
- scipy/fft/_basic_backend.py +197 -0
- scipy/fft/_debug_backends.py +22 -0
- scipy/fft/_fftlog.py +223 -0
- scipy/fft/_fftlog_backend.py +200 -0
- scipy/fft/_helper.py +348 -0
- scipy/fft/_pocketfft/LICENSE.md +25 -0
- scipy/fft/_pocketfft/__init__.py +9 -0
- scipy/fft/_pocketfft/basic.py +251 -0
- scipy/fft/_pocketfft/helper.py +249 -0
- scipy/fft/_pocketfft/pypocketfft.cp314-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp314-win_arm64.pyd +0 -0
- scipy/fft/_pocketfft/realtransforms.py +109 -0
- scipy/fft/_pocketfft/tests/__init__.py +0 -0
- scipy/fft/_pocketfft/tests/test_basic.py +1011 -0
- scipy/fft/_pocketfft/tests/test_real_transforms.py +505 -0
- scipy/fft/_realtransforms.py +706 -0
- scipy/fft/_realtransforms_backend.py +63 -0
- scipy/fft/tests/__init__.py +0 -0
- scipy/fft/tests/mock_backend.py +96 -0
- scipy/fft/tests/test_backend.py +98 -0
- scipy/fft/tests/test_basic.py +504 -0
- scipy/fft/tests/test_fftlog.py +215 -0
- scipy/fft/tests/test_helper.py +558 -0
- scipy/fft/tests/test_multithreading.py +84 -0
- scipy/fft/tests/test_real_transforms.py +247 -0
- scipy/fftpack/__init__.py +103 -0
- scipy/fftpack/_basic.py +428 -0
- scipy/fftpack/_helper.py +115 -0
- scipy/fftpack/_pseudo_diffs.py +554 -0
- scipy/fftpack/_realtransforms.py +598 -0
- scipy/fftpack/basic.py +20 -0
- scipy/fftpack/convolve.cp314-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp314-win_arm64.pyd +0 -0
- scipy/fftpack/helper.py +19 -0
- scipy/fftpack/pseudo_diffs.py +22 -0
- scipy/fftpack/realtransforms.py +19 -0
- scipy/fftpack/tests/__init__.py +0 -0
- scipy/fftpack/tests/fftw_double_ref.npz +0 -0
- scipy/fftpack/tests/fftw_longdouble_ref.npz +0 -0
- scipy/fftpack/tests/fftw_single_ref.npz +0 -0
- scipy/fftpack/tests/test.npz +0 -0
- scipy/fftpack/tests/test_basic.py +877 -0
- scipy/fftpack/tests/test_helper.py +54 -0
- scipy/fftpack/tests/test_import.py +33 -0
- scipy/fftpack/tests/test_pseudo_diffs.py +388 -0
- scipy/fftpack/tests/test_real_transforms.py +836 -0
- scipy/integrate/__init__.py +122 -0
- scipy/integrate/_bvp.py +1160 -0
- scipy/integrate/_cubature.py +729 -0
- scipy/integrate/_dop.cp314-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_ivp/__init__.py +8 -0
- scipy/integrate/_ivp/base.py +290 -0
- scipy/integrate/_ivp/bdf.py +478 -0
- scipy/integrate/_ivp/common.py +451 -0
- scipy/integrate/_ivp/dop853_coefficients.py +193 -0
- scipy/integrate/_ivp/ivp.py +755 -0
- scipy/integrate/_ivp/lsoda.py +224 -0
- scipy/integrate/_ivp/radau.py +572 -0
- scipy/integrate/_ivp/rk.py +601 -0
- scipy/integrate/_ivp/tests/__init__.py +0 -0
- scipy/integrate/_ivp/tests/test_ivp.py +1287 -0
- scipy/integrate/_ivp/tests/test_rk.py +37 -0
- scipy/integrate/_lebedev.py +5450 -0
- scipy/integrate/_lsoda.cp314-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp314-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp314-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_quadpack_py.py +1283 -0
- scipy/integrate/_quadrature.py +1336 -0
- scipy/integrate/_rules/__init__.py +12 -0
- scipy/integrate/_rules/_base.py +518 -0
- scipy/integrate/_rules/_gauss_kronrod.py +202 -0
- scipy/integrate/_rules/_gauss_legendre.py +62 -0
- scipy/integrate/_rules/_genz_malik.py +210 -0
- scipy/integrate/_tanhsinh.py +1385 -0
- scipy/integrate/_test_multivariate.cp314-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp314-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp314-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp314-win_arm64.pyd +0 -0
- scipy/integrate/dop.py +15 -0
- scipy/integrate/lsoda.py +15 -0
- scipy/integrate/odepack.py +17 -0
- scipy/integrate/quadpack.py +23 -0
- scipy/integrate/tests/__init__.py +0 -0
- scipy/integrate/tests/test__quad_vec.py +211 -0
- scipy/integrate/tests/test_banded_ode_solvers.py +305 -0
- scipy/integrate/tests/test_bvp.py +714 -0
- scipy/integrate/tests/test_cubature.py +1375 -0
- scipy/integrate/tests/test_integrate.py +840 -0
- scipy/integrate/tests/test_odeint_jac.py +74 -0
- scipy/integrate/tests/test_quadpack.py +680 -0
- scipy/integrate/tests/test_quadrature.py +730 -0
- scipy/integrate/tests/test_tanhsinh.py +1171 -0
- scipy/integrate/vode.py +15 -0
- scipy/interpolate/__init__.py +228 -0
- scipy/interpolate/_bary_rational.py +715 -0
- scipy/interpolate/_bsplines.py +2469 -0
- scipy/interpolate/_cubic.py +973 -0
- scipy/interpolate/_dfitpack.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack2.py +2397 -0
- scipy/interpolate/_fitpack_impl.py +811 -0
- scipy/interpolate/_fitpack_py.py +898 -0
- scipy/interpolate/_fitpack_repro.py +996 -0
- scipy/interpolate/_interpnd.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_interpolate.py +2266 -0
- scipy/interpolate/_ndbspline.py +415 -0
- scipy/interpolate/_ndgriddata.py +329 -0
- scipy/interpolate/_pade.py +67 -0
- scipy/interpolate/_polyint.py +1025 -0
- scipy/interpolate/_ppoly.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/dfitpack.py +24 -0
- scipy/interpolate/fitpack.py +31 -0
- scipy/interpolate/fitpack2.py +29 -0
- scipy/interpolate/interpnd.py +24 -0
- scipy/interpolate/interpolate.py +30 -0
- scipy/interpolate/ndgriddata.py +23 -0
- scipy/interpolate/polyint.py +24 -0
- scipy/interpolate/rbf.py +18 -0
- scipy/interpolate/tests/__init__.py +0 -0
- scipy/interpolate/tests/data/bug-1310.npz +0 -0
- scipy/interpolate/tests/data/estimate_gradients_hang.npy +0 -0
- scipy/interpolate/tests/data/gcvspl.npz +0 -0
- scipy/interpolate/tests/test_bary_rational.py +368 -0
- scipy/interpolate/tests/test_bsplines.py +3754 -0
- scipy/interpolate/tests/test_fitpack.py +519 -0
- scipy/interpolate/tests/test_fitpack2.py +1431 -0
- scipy/interpolate/tests/test_gil.py +64 -0
- scipy/interpolate/tests/test_interpnd.py +452 -0
- scipy/interpolate/tests/test_interpolate.py +2630 -0
- scipy/interpolate/tests/test_ndgriddata.py +308 -0
- scipy/interpolate/tests/test_pade.py +107 -0
- scipy/interpolate/tests/test_polyint.py +972 -0
- scipy/interpolate/tests/test_rbf.py +246 -0
- scipy/interpolate/tests/test_rbfinterp.py +534 -0
- scipy/interpolate/tests/test_rgi.py +1151 -0
- scipy/io/__init__.py +116 -0
- scipy/io/_fast_matrix_market/__init__.py +600 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp314-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp314-win_arm64.pyd +0 -0
- scipy/io/_fortran.py +354 -0
- scipy/io/_harwell_boeing/__init__.py +7 -0
- scipy/io/_harwell_boeing/_fortran_format_parser.py +316 -0
- scipy/io/_harwell_boeing/hb.py +571 -0
- scipy/io/_harwell_boeing/tests/__init__.py +0 -0
- scipy/io/_harwell_boeing/tests/test_fortran_format.py +74 -0
- scipy/io/_harwell_boeing/tests/test_hb.py +70 -0
- scipy/io/_idl.py +917 -0
- scipy/io/_mmio.py +968 -0
- scipy/io/_netcdf.py +1104 -0
- scipy/io/_test_fortran.cp314-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp314-win_arm64.pyd +0 -0
- scipy/io/arff/__init__.py +28 -0
- scipy/io/arff/_arffread.py +873 -0
- scipy/io/arff/arffread.py +19 -0
- scipy/io/arff/tests/__init__.py +0 -0
- scipy/io/arff/tests/data/iris.arff +225 -0
- scipy/io/arff/tests/data/missing.arff +8 -0
- scipy/io/arff/tests/data/nodata.arff +11 -0
- scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
- scipy/io/arff/tests/data/quoted_nominal_spaces.arff +13 -0
- scipy/io/arff/tests/data/test1.arff +10 -0
- scipy/io/arff/tests/data/test10.arff +8 -0
- scipy/io/arff/tests/data/test11.arff +11 -0
- scipy/io/arff/tests/data/test2.arff +15 -0
- scipy/io/arff/tests/data/test3.arff +6 -0
- scipy/io/arff/tests/data/test4.arff +11 -0
- scipy/io/arff/tests/data/test5.arff +26 -0
- scipy/io/arff/tests/data/test6.arff +12 -0
- scipy/io/arff/tests/data/test7.arff +15 -0
- scipy/io/arff/tests/data/test8.arff +12 -0
- scipy/io/arff/tests/data/test9.arff +14 -0
- scipy/io/arff/tests/test_arffread.py +421 -0
- scipy/io/harwell_boeing.py +17 -0
- scipy/io/idl.py +17 -0
- scipy/io/matlab/__init__.py +66 -0
- scipy/io/matlab/_byteordercodes.py +75 -0
- scipy/io/matlab/_mio.py +375 -0
- scipy/io/matlab/_mio4.py +632 -0
- scipy/io/matlab/_mio5.py +901 -0
- scipy/io/matlab/_mio5_params.py +281 -0
- scipy/io/matlab/_mio5_utils.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp314-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp314-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp314-win_arm64.pyd +0 -0
- scipy/io/matlab/byteordercodes.py +17 -0
- scipy/io/matlab/mio.py +16 -0
- scipy/io/matlab/mio4.py +17 -0
- scipy/io/matlab/mio5.py +19 -0
- scipy/io/matlab/mio5_params.py +18 -0
- scipy/io/matlab/mio5_utils.py +17 -0
- scipy/io/matlab/mio_utils.py +17 -0
- scipy/io/matlab/miobase.py +16 -0
- scipy/io/matlab/streams.py +16 -0
- scipy/io/matlab/tests/__init__.py +0 -0
- scipy/io/matlab/tests/data/bad_miuint32.mat +0 -0
- scipy/io/matlab/tests/data/bad_miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/big_endian.mat +0 -0
- scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_checksum.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_data.mat +0 -0
- scipy/io/matlab/tests/data/debigged_m4.mat +0 -0
- scipy/io/matlab/tests/data/japanese_utf8.txt +5 -0
- scipy/io/matlab/tests/data/little_endian.mat +0 -0
- scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
- scipy/io/matlab/tests/data/malformed1.mat +0 -0
- scipy/io/matlab/tests/data/miuint32_for_miint32.mat +0 -0
- scipy/io/matlab/tests/data/miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/nasty_duplicate_fieldnames.mat +0 -0
- scipy/io/matlab/tests/data/one_by_zero_char.mat +0 -0
- scipy/io/matlab/tests/data/parabola.mat +0 -0
- scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
- scipy/io/matlab/tests/data/some_functions.mat +0 -0
- scipy/io/matlab/tests/data/sqr.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test_empty_struct.mat +0 -0
- scipy/io/matlab/tests/data/test_mat4_le_floats.mat +0 -0
- scipy/io/matlab/tests/data/test_skip_variable.mat +0 -0
- scipy/io/matlab/tests/data/testbool_8_WIN64.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_5.3_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testhdf5_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsimplecell.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testvec_4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/test_byteordercodes.py +29 -0
- scipy/io/matlab/tests/test_mio.py +1399 -0
- scipy/io/matlab/tests/test_mio5_utils.py +179 -0
- scipy/io/matlab/tests/test_mio_funcs.py +51 -0
- scipy/io/matlab/tests/test_mio_utils.py +45 -0
- scipy/io/matlab/tests/test_miobase.py +32 -0
- scipy/io/matlab/tests/test_pathological.py +33 -0
- scipy/io/matlab/tests/test_streams.py +241 -0
- scipy/io/mmio.py +17 -0
- scipy/io/netcdf.py +17 -0
- scipy/io/tests/__init__.py +0 -0
- scipy/io/tests/data/Transparent Busy.ani +0 -0
- scipy/io/tests/data/array_float32_1d.sav +0 -0
- scipy/io/tests/data/array_float32_2d.sav +0 -0
- scipy/io/tests/data/array_float32_3d.sav +0 -0
- scipy/io/tests/data/array_float32_4d.sav +0 -0
- scipy/io/tests/data/array_float32_5d.sav +0 -0
- scipy/io/tests/data/array_float32_6d.sav +0 -0
- scipy/io/tests/data/array_float32_7d.sav +0 -0
- scipy/io/tests/data/array_float32_8d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_1d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_2d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_3d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_4d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_5d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_6d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_7d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_8d.sav +0 -0
- scipy/io/tests/data/example_1.nc +0 -0
- scipy/io/tests/data/example_2.nc +0 -0
- scipy/io/tests/data/example_3_maskedvals.nc +0 -0
- scipy/io/tests/data/fortran-3x3d-2i.dat +0 -0
- scipy/io/tests/data/fortran-mixed.dat +0 -0
- scipy/io/tests/data/fortran-sf8-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-sf8-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x3x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-si4-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x3x5.dat +0 -0
- scipy/io/tests/data/invalid_pointer.sav +0 -0
- scipy/io/tests/data/null_pointer.sav +0 -0
- scipy/io/tests/data/scalar_byte.sav +0 -0
- scipy/io/tests/data/scalar_byte_descr.sav +0 -0
- scipy/io/tests/data/scalar_complex32.sav +0 -0
- scipy/io/tests/data/scalar_complex64.sav +0 -0
- scipy/io/tests/data/scalar_float32.sav +0 -0
- scipy/io/tests/data/scalar_float64.sav +0 -0
- scipy/io/tests/data/scalar_heap_pointer.sav +0 -0
- scipy/io/tests/data/scalar_int16.sav +0 -0
- scipy/io/tests/data/scalar_int32.sav +0 -0
- scipy/io/tests/data/scalar_int64.sav +0 -0
- scipy/io/tests/data/scalar_string.sav +0 -0
- scipy/io/tests/data/scalar_uint16.sav +0 -0
- scipy/io/tests/data/scalar_uint32.sav +0 -0
- scipy/io/tests/data/scalar_uint64.sav +0 -0
- scipy/io/tests/data/struct_arrays.sav +0 -0
- scipy/io/tests/data/struct_arrays_byte_idl80.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_inherit.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_pointers.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_scalars.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated_3d.sav +0 -0
- scipy/io/tests/data/test-1234Hz-le-1ch-10S-20bit-extra.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-be.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-le.wav +0 -0
- scipy/io/tests/data/test-44100Hz-be-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof-no-data.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-rf64.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-48000Hz-2ch-64bit-float-le-wavex.wav +0 -0
- scipy/io/tests/data/test-8000Hz-be-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-1ch-1byte-ulaw.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-2ch-1byteu.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-inconsistent.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-rf64.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-36bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-45bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-53bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-64bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-4ch-9S-12bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-5ch-9S-5bit.wav +0 -0
- scipy/io/tests/data/various_compressed.sav +0 -0
- scipy/io/tests/test_fortran.py +264 -0
- scipy/io/tests/test_idl.py +483 -0
- scipy/io/tests/test_mmio.py +831 -0
- scipy/io/tests/test_netcdf.py +550 -0
- scipy/io/tests/test_paths.py +93 -0
- scipy/io/tests/test_wavfile.py +501 -0
- scipy/io/wavfile.py +938 -0
- scipy/linalg/__init__.pxd +1 -0
- scipy/linalg/__init__.py +236 -0
- scipy/linalg/_basic.py +2146 -0
- scipy/linalg/_blas_subroutines.h +164 -0
- scipy/linalg/_cythonized_array_utils.cp314-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_cythonized_array_utils.pxd +40 -0
- scipy/linalg/_cythonized_array_utils.pyi +16 -0
- scipy/linalg/_decomp.py +1645 -0
- scipy/linalg/_decomp_cholesky.py +413 -0
- scipy/linalg/_decomp_cossin.py +236 -0
- scipy/linalg/_decomp_interpolative.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_lu_cython.pyi +6 -0
- scipy/linalg/_decomp_polar.py +113 -0
- scipy/linalg/_decomp_qr.py +494 -0
- scipy/linalg/_decomp_qz.py +452 -0
- scipy/linalg/_decomp_schur.py +336 -0
- scipy/linalg/_decomp_svd.py +545 -0
- scipy/linalg/_decomp_update.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp314-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp314-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp314-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_expm.pyi +6 -0
- scipy/linalg/_matfuncs_inv_ssq.py +886 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_misc.py +191 -0
- scipy/linalg/_procrustes.py +113 -0
- scipy/linalg/_sketches.py +189 -0
- scipy/linalg/_solve_toeplitz.cp314-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_solvers.py +862 -0
- scipy/linalg/_special_matrices.py +1322 -0
- scipy/linalg/_testutils.py +65 -0
- scipy/linalg/basic.py +23 -0
- scipy/linalg/blas.py +495 -0
- scipy/linalg/cython_blas.cp314-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp314-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp314-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp314-win_arm64.pyd +0 -0
- scipy/linalg/cython_lapack.pxd +1528 -0
- scipy/linalg/cython_lapack.pyx +12045 -0
- scipy/linalg/decomp.py +23 -0
- scipy/linalg/decomp_cholesky.py +21 -0
- scipy/linalg/decomp_lu.py +21 -0
- scipy/linalg/decomp_qr.py +20 -0
- scipy/linalg/decomp_schur.py +21 -0
- scipy/linalg/decomp_svd.py +21 -0
- scipy/linalg/interpolative.py +989 -0
- scipy/linalg/lapack.py +1081 -0
- scipy/linalg/matfuncs.py +23 -0
- scipy/linalg/misc.py +21 -0
- scipy/linalg/special_matrices.py +22 -0
- scipy/linalg/tests/__init__.py +0 -0
- scipy/linalg/tests/_cython_examples/extending.pyx +23 -0
- scipy/linalg/tests/_cython_examples/meson.build +34 -0
- scipy/linalg/tests/data/carex_15_data.npz +0 -0
- scipy/linalg/tests/data/carex_18_data.npz +0 -0
- scipy/linalg/tests/data/carex_19_data.npz +0 -0
- scipy/linalg/tests/data/carex_20_data.npz +0 -0
- scipy/linalg/tests/data/carex_6_data.npz +0 -0
- scipy/linalg/tests/data/gendare_20170120_data.npz +0 -0
- scipy/linalg/tests/test_basic.py +2074 -0
- scipy/linalg/tests/test_batch.py +588 -0
- scipy/linalg/tests/test_blas.py +1127 -0
- scipy/linalg/tests/test_cython_blas.py +118 -0
- scipy/linalg/tests/test_cython_lapack.py +22 -0
- scipy/linalg/tests/test_cythonized_array_utils.py +130 -0
- scipy/linalg/tests/test_decomp.py +3189 -0
- scipy/linalg/tests/test_decomp_cholesky.py +268 -0
- scipy/linalg/tests/test_decomp_cossin.py +314 -0
- scipy/linalg/tests/test_decomp_ldl.py +137 -0
- scipy/linalg/tests/test_decomp_lu.py +308 -0
- scipy/linalg/tests/test_decomp_polar.py +110 -0
- scipy/linalg/tests/test_decomp_update.py +1701 -0
- scipy/linalg/tests/test_extending.py +46 -0
- scipy/linalg/tests/test_fblas.py +607 -0
- scipy/linalg/tests/test_interpolative.py +232 -0
- scipy/linalg/tests/test_lapack.py +3620 -0
- scipy/linalg/tests/test_matfuncs.py +1125 -0
- scipy/linalg/tests/test_matmul_toeplitz.py +136 -0
- scipy/linalg/tests/test_procrustes.py +214 -0
- scipy/linalg/tests/test_sketches.py +118 -0
- scipy/linalg/tests/test_solve_toeplitz.py +150 -0
- scipy/linalg/tests/test_solvers.py +844 -0
- scipy/linalg/tests/test_special_matrices.py +636 -0
- scipy/misc/__init__.py +6 -0
- scipy/misc/common.py +6 -0
- scipy/misc/doccer.py +6 -0
- scipy/ndimage/__init__.py +174 -0
- scipy/ndimage/_ctest.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_delegators.py +303 -0
- scipy/ndimage/_filters.py +2422 -0
- scipy/ndimage/_fourier.py +306 -0
- scipy/ndimage/_interpolation.py +1033 -0
- scipy/ndimage/_measurements.py +1689 -0
- scipy/ndimage/_morphology.py +2634 -0
- scipy/ndimage/_nd_image.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_support_alternative_backends.py +84 -0
- scipy/ndimage/filters.py +27 -0
- scipy/ndimage/fourier.py +21 -0
- scipy/ndimage/interpolation.py +22 -0
- scipy/ndimage/measurements.py +24 -0
- scipy/ndimage/morphology.py +27 -0
- scipy/ndimage/tests/__init__.py +12 -0
- scipy/ndimage/tests/data/label_inputs.txt +21 -0
- scipy/ndimage/tests/data/label_results.txt +294 -0
- scipy/ndimage/tests/data/label_strels.txt +42 -0
- scipy/ndimage/tests/dots.png +0 -0
- scipy/ndimage/tests/test_c_api.py +102 -0
- scipy/ndimage/tests/test_datatypes.py +67 -0
- scipy/ndimage/tests/test_filters.py +3083 -0
- scipy/ndimage/tests/test_fourier.py +187 -0
- scipy/ndimage/tests/test_interpolation.py +1491 -0
- scipy/ndimage/tests/test_measurements.py +1592 -0
- scipy/ndimage/tests/test_morphology.py +2950 -0
- scipy/ndimage/tests/test_ni_support.py +78 -0
- scipy/ndimage/tests/test_splines.py +70 -0
- scipy/odr/__init__.py +131 -0
- scipy/odr/__odrpack.cp314-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp314-win_arm64.pyd +0 -0
- scipy/odr/_add_newdocs.py +34 -0
- scipy/odr/_models.py +315 -0
- scipy/odr/_odrpack.py +1154 -0
- scipy/odr/models.py +20 -0
- scipy/odr/odrpack.py +21 -0
- scipy/odr/tests/__init__.py +0 -0
- scipy/odr/tests/test_odr.py +607 -0
- scipy/optimize/__init__.pxd +1 -0
- scipy/optimize/__init__.py +460 -0
- scipy/optimize/_basinhopping.py +741 -0
- scipy/optimize/_bglu_dense.cp314-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_bracket.py +706 -0
- scipy/optimize/_chandrupatla.py +551 -0
- scipy/optimize/_cobyla_py.py +297 -0
- scipy/optimize/_cobyqa_py.py +72 -0
- scipy/optimize/_constraints.py +598 -0
- scipy/optimize/_dcsrch.py +728 -0
- scipy/optimize/_differentiable_functions.py +835 -0
- scipy/optimize/_differentialevolution.py +1970 -0
- scipy/optimize/_direct.cp314-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_direct_py.py +280 -0
- scipy/optimize/_dual_annealing.py +732 -0
- scipy/optimize/_elementwise.py +798 -0
- scipy/optimize/_group_columns.cp314-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp314-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp314-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_lbfgsb_py.py +634 -0
- scipy/optimize/_linesearch.py +896 -0
- scipy/optimize/_linprog.py +733 -0
- scipy/optimize/_linprog_doc.py +1434 -0
- scipy/optimize/_linprog_highs.py +422 -0
- scipy/optimize/_linprog_ip.py +1141 -0
- scipy/optimize/_linprog_rs.py +572 -0
- scipy/optimize/_linprog_simplex.py +663 -0
- scipy/optimize/_linprog_util.py +1521 -0
- scipy/optimize/_lsap.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/__init__.py +5 -0
- scipy/optimize/_lsq/bvls.py +183 -0
- scipy/optimize/_lsq/common.py +731 -0
- scipy/optimize/_lsq/dogbox.py +345 -0
- scipy/optimize/_lsq/givens_elimination.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/least_squares.py +1044 -0
- scipy/optimize/_lsq/lsq_linear.py +361 -0
- scipy/optimize/_lsq/trf.py +587 -0
- scipy/optimize/_lsq/trf_linear.py +249 -0
- scipy/optimize/_milp.py +394 -0
- scipy/optimize/_minimize.py +1199 -0
- scipy/optimize/_minpack.cp314-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp314-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_nnls.py +96 -0
- scipy/optimize/_nonlin.py +1634 -0
- scipy/optimize/_numdiff.py +963 -0
- scipy/optimize/_optimize.py +4169 -0
- scipy/optimize/_pava_pybind.cp314-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_qap.py +760 -0
- scipy/optimize/_remove_redundancy.py +522 -0
- scipy/optimize/_root.py +732 -0
- scipy/optimize/_root_scalar.py +538 -0
- scipy/optimize/_shgo.py +1606 -0
- scipy/optimize/_shgo_lib/__init__.py +0 -0
- scipy/optimize/_shgo_lib/_complex.py +1225 -0
- scipy/optimize/_shgo_lib/_vertex.py +460 -0
- scipy/optimize/_slsqp_py.py +603 -0
- scipy/optimize/_slsqplib.cp314-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_spectral.py +260 -0
- scipy/optimize/_tnc.py +438 -0
- scipy/optimize/_trlib/__init__.py +12 -0
- scipy/optimize/_trlib/_trlib.cp314-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_trustregion.py +318 -0
- scipy/optimize/_trustregion_constr/__init__.py +6 -0
- scipy/optimize/_trustregion_constr/canonical_constraint.py +390 -0
- scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +231 -0
- scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +584 -0
- scipy/optimize/_trustregion_constr/projections.py +411 -0
- scipy/optimize/_trustregion_constr/qp_subproblem.py +637 -0
- scipy/optimize/_trustregion_constr/report.py +49 -0
- scipy/optimize/_trustregion_constr/tests/__init__.py +0 -0
- scipy/optimize/_trustregion_constr/tests/test_canonical_constraint.py +296 -0
- scipy/optimize/_trustregion_constr/tests/test_nested_minimize.py +39 -0
- scipy/optimize/_trustregion_constr/tests/test_projections.py +214 -0
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +645 -0
- scipy/optimize/_trustregion_constr/tests/test_report.py +34 -0
- scipy/optimize/_trustregion_constr/tr_interior_point.py +361 -0
- scipy/optimize/_trustregion_dogleg.py +122 -0
- scipy/optimize/_trustregion_exact.py +437 -0
- scipy/optimize/_trustregion_krylov.py +65 -0
- scipy/optimize/_trustregion_ncg.py +126 -0
- scipy/optimize/_tstutils.py +972 -0
- scipy/optimize/_zeros.cp314-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_zeros_py.py +1475 -0
- scipy/optimize/cobyla.py +19 -0
- scipy/optimize/cython_optimize/__init__.py +133 -0
- scipy/optimize/cython_optimize/_zeros.cp314-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp314-win_arm64.pyd +0 -0
- scipy/optimize/cython_optimize/_zeros.pxd +33 -0
- scipy/optimize/cython_optimize/c_zeros.pxd +26 -0
- scipy/optimize/cython_optimize.pxd +11 -0
- scipy/optimize/elementwise.py +38 -0
- scipy/optimize/lbfgsb.py +23 -0
- scipy/optimize/linesearch.py +18 -0
- scipy/optimize/minpack.py +27 -0
- scipy/optimize/minpack2.py +17 -0
- scipy/optimize/moduleTNC.py +19 -0
- scipy/optimize/nonlin.py +29 -0
- scipy/optimize/optimize.py +40 -0
- scipy/optimize/slsqp.py +22 -0
- scipy/optimize/tests/__init__.py +0 -0
- scipy/optimize/tests/_cython_examples/extending.pyx +43 -0
- scipy/optimize/tests/_cython_examples/meson.build +32 -0
- scipy/optimize/tests/test__basinhopping.py +535 -0
- scipy/optimize/tests/test__differential_evolution.py +1703 -0
- scipy/optimize/tests/test__dual_annealing.py +416 -0
- scipy/optimize/tests/test__linprog_clean_inputs.py +312 -0
- scipy/optimize/tests/test__numdiff.py +885 -0
- scipy/optimize/tests/test__remove_redundancy.py +228 -0
- scipy/optimize/tests/test__root.py +124 -0
- scipy/optimize/tests/test__shgo.py +1164 -0
- scipy/optimize/tests/test__spectral.py +226 -0
- scipy/optimize/tests/test_bracket.py +896 -0
- scipy/optimize/tests/test_chandrupatla.py +982 -0
- scipy/optimize/tests/test_cobyla.py +195 -0
- scipy/optimize/tests/test_cobyqa.py +252 -0
- scipy/optimize/tests/test_constraint_conversion.py +286 -0
- scipy/optimize/tests/test_constraints.py +255 -0
- scipy/optimize/tests/test_cython_optimize.py +92 -0
- scipy/optimize/tests/test_differentiable_functions.py +1025 -0
- scipy/optimize/tests/test_direct.py +321 -0
- scipy/optimize/tests/test_extending.py +28 -0
- scipy/optimize/tests/test_hessian_update_strategy.py +300 -0
- scipy/optimize/tests/test_isotonic_regression.py +167 -0
- scipy/optimize/tests/test_lbfgsb_hessinv.py +65 -0
- scipy/optimize/tests/test_lbfgsb_setulb.py +122 -0
- scipy/optimize/tests/test_least_squares.py +986 -0
- scipy/optimize/tests/test_linear_assignment.py +116 -0
- scipy/optimize/tests/test_linesearch.py +328 -0
- scipy/optimize/tests/test_linprog.py +2577 -0
- scipy/optimize/tests/test_lsq_common.py +297 -0
- scipy/optimize/tests/test_lsq_linear.py +287 -0
- scipy/optimize/tests/test_milp.py +459 -0
- scipy/optimize/tests/test_minimize_constrained.py +845 -0
- scipy/optimize/tests/test_minpack.py +1194 -0
- scipy/optimize/tests/test_nnls.py +469 -0
- scipy/optimize/tests/test_nonlin.py +572 -0
- scipy/optimize/tests/test_optimize.py +3344 -0
- scipy/optimize/tests/test_quadratic_assignment.py +455 -0
- scipy/optimize/tests/test_regression.py +40 -0
- scipy/optimize/tests/test_slsqp.py +645 -0
- scipy/optimize/tests/test_tnc.py +345 -0
- scipy/optimize/tests/test_trustregion.py +110 -0
- scipy/optimize/tests/test_trustregion_exact.py +351 -0
- scipy/optimize/tests/test_trustregion_krylov.py +170 -0
- scipy/optimize/tests/test_zeros.py +998 -0
- scipy/optimize/tnc.py +22 -0
- scipy/optimize/zeros.py +26 -0
- scipy/signal/__init__.py +316 -0
- scipy/signal/_arraytools.py +264 -0
- scipy/signal/_czt.py +575 -0
- scipy/signal/_delegators.py +568 -0
- scipy/signal/_filter_design.py +5893 -0
- scipy/signal/_fir_filter_design.py +1458 -0
- scipy/signal/_lti_conversion.py +534 -0
- scipy/signal/_ltisys.py +3546 -0
- scipy/signal/_max_len_seq.py +139 -0
- scipy/signal/_max_len_seq_inner.cp314-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp314-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp314-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp314-win_arm64.pyd +0 -0
- scipy/signal/_polyutils.py +172 -0
- scipy/signal/_savitzky_golay.py +357 -0
- scipy/signal/_short_time_fft.py +2228 -0
- scipy/signal/_signal_api.py +30 -0
- scipy/signal/_signaltools.py +5309 -0
- scipy/signal/_sigtools.cp314-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp314-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp314-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp314-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp314-win_arm64.lib +0 -0
- scipy/signal/_spline.cp314-win_arm64.pyd +0 -0
- scipy/signal/_spline.pyi +34 -0
- scipy/signal/_spline_filters.py +848 -0
- scipy/signal/_support_alternative_backends.py +73 -0
- scipy/signal/_upfirdn.py +219 -0
- scipy/signal/_upfirdn_apply.cp314-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp314-win_arm64.pyd +0 -0
- scipy/signal/_waveforms.py +687 -0
- scipy/signal/_wavelets.py +29 -0
- scipy/signal/bsplines.py +21 -0
- scipy/signal/filter_design.py +28 -0
- scipy/signal/fir_filter_design.py +21 -0
- scipy/signal/lti_conversion.py +20 -0
- scipy/signal/ltisys.py +25 -0
- scipy/signal/signaltools.py +27 -0
- scipy/signal/spectral.py +21 -0
- scipy/signal/spline.py +18 -0
- scipy/signal/tests/__init__.py +0 -0
- scipy/signal/tests/_scipy_spectral_test_shim.py +311 -0
- scipy/signal/tests/mpsig.py +122 -0
- scipy/signal/tests/test_array_tools.py +111 -0
- scipy/signal/tests/test_bsplines.py +365 -0
- scipy/signal/tests/test_cont2discrete.py +424 -0
- scipy/signal/tests/test_czt.py +221 -0
- scipy/signal/tests/test_dltisys.py +599 -0
- scipy/signal/tests/test_filter_design.py +4744 -0
- scipy/signal/tests/test_fir_filter_design.py +851 -0
- scipy/signal/tests/test_ltisys.py +1225 -0
- scipy/signal/tests/test_max_len_seq.py +71 -0
- scipy/signal/tests/test_peak_finding.py +915 -0
- scipy/signal/tests/test_result_type.py +51 -0
- scipy/signal/tests/test_savitzky_golay.py +363 -0
- scipy/signal/tests/test_short_time_fft.py +1107 -0
- scipy/signal/tests/test_signaltools.py +4735 -0
- scipy/signal/tests/test_spectral.py +2141 -0
- scipy/signal/tests/test_splines.py +427 -0
- scipy/signal/tests/test_upfirdn.py +322 -0
- scipy/signal/tests/test_waveforms.py +400 -0
- scipy/signal/tests/test_wavelets.py +59 -0
- scipy/signal/tests/test_windows.py +987 -0
- scipy/signal/waveforms.py +20 -0
- scipy/signal/wavelets.py +17 -0
- scipy/signal/windows/__init__.py +52 -0
- scipy/signal/windows/_windows.py +2513 -0
- scipy/signal/windows/windows.py +23 -0
- scipy/sparse/__init__.py +350 -0
- scipy/sparse/_base.py +1613 -0
- scipy/sparse/_bsr.py +880 -0
- scipy/sparse/_compressed.py +1328 -0
- scipy/sparse/_construct.py +1454 -0
- scipy/sparse/_coo.py +1581 -0
- scipy/sparse/_csc.py +367 -0
- scipy/sparse/_csparsetools.cp314-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp314-win_arm64.pyd +0 -0
- scipy/sparse/_csr.py +558 -0
- scipy/sparse/_data.py +569 -0
- scipy/sparse/_dia.py +677 -0
- scipy/sparse/_dok.py +669 -0
- scipy/sparse/_extract.py +178 -0
- scipy/sparse/_index.py +444 -0
- scipy/sparse/_lil.py +632 -0
- scipy/sparse/_matrix.py +169 -0
- scipy/sparse/_matrix_io.py +167 -0
- scipy/sparse/_sparsetools.cp314-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp314-win_arm64.pyd +0 -0
- scipy/sparse/_spfuncs.py +76 -0
- scipy/sparse/_sputils.py +632 -0
- scipy/sparse/base.py +24 -0
- scipy/sparse/bsr.py +22 -0
- scipy/sparse/compressed.py +20 -0
- scipy/sparse/construct.py +38 -0
- scipy/sparse/coo.py +23 -0
- scipy/sparse/csc.py +22 -0
- scipy/sparse/csgraph/__init__.py +210 -0
- scipy/sparse/csgraph/_flow.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_validation.py +66 -0
- scipy/sparse/csgraph/tests/__init__.py +0 -0
- scipy/sparse/csgraph/tests/test_connected_components.py +119 -0
- scipy/sparse/csgraph/tests/test_conversions.py +61 -0
- scipy/sparse/csgraph/tests/test_flow.py +209 -0
- scipy/sparse/csgraph/tests/test_graph_laplacian.py +368 -0
- scipy/sparse/csgraph/tests/test_matching.py +307 -0
- scipy/sparse/csgraph/tests/test_pydata_sparse.py +197 -0
- scipy/sparse/csgraph/tests/test_reordering.py +70 -0
- scipy/sparse/csgraph/tests/test_shortest_path.py +540 -0
- scipy/sparse/csgraph/tests/test_spanning_tree.py +66 -0
- scipy/sparse/csgraph/tests/test_traversal.py +148 -0
- scipy/sparse/csr.py +22 -0
- scipy/sparse/data.py +18 -0
- scipy/sparse/dia.py +22 -0
- scipy/sparse/dok.py +22 -0
- scipy/sparse/extract.py +23 -0
- scipy/sparse/lil.py +22 -0
- scipy/sparse/linalg/__init__.py +148 -0
- scipy/sparse/linalg/_dsolve/__init__.py +71 -0
- scipy/sparse/linalg/_dsolve/_add_newdocs.py +147 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_dsolve/linsolve.py +882 -0
- scipy/sparse/linalg/_dsolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +928 -0
- scipy/sparse/linalg/_eigen/__init__.py +22 -0
- scipy/sparse/linalg/_eigen/_svds.py +540 -0
- scipy/sparse/linalg/_eigen/_svds_doc.py +382 -0
- scipy/sparse/linalg/_eigen/arpack/COPYING +45 -0
- scipy/sparse/linalg/_eigen/arpack/__init__.py +20 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_eigen/arpack/arpack.py +1706 -0
- scipy/sparse/linalg/_eigen/arpack/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/arpack/tests/test_arpack.py +717 -0
- scipy/sparse/linalg/_eigen/lobpcg/__init__.py +16 -0
- scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +1110 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py +725 -0
- scipy/sparse/linalg/_eigen/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/tests/test_svds.py +886 -0
- scipy/sparse/linalg/_expm_multiply.py +816 -0
- scipy/sparse/linalg/_interface.py +920 -0
- scipy/sparse/linalg/_isolve/__init__.py +20 -0
- scipy/sparse/linalg/_isolve/_gcrotmk.py +503 -0
- scipy/sparse/linalg/_isolve/iterative.py +1051 -0
- scipy/sparse/linalg/_isolve/lgmres.py +230 -0
- scipy/sparse/linalg/_isolve/lsmr.py +486 -0
- scipy/sparse/linalg/_isolve/lsqr.py +589 -0
- scipy/sparse/linalg/_isolve/minres.py +372 -0
- scipy/sparse/linalg/_isolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_isolve/tests/test_gcrotmk.py +183 -0
- scipy/sparse/linalg/_isolve/tests/test_iterative.py +809 -0
- scipy/sparse/linalg/_isolve/tests/test_lgmres.py +225 -0
- scipy/sparse/linalg/_isolve/tests/test_lsmr.py +185 -0
- scipy/sparse/linalg/_isolve/tests/test_lsqr.py +120 -0
- scipy/sparse/linalg/_isolve/tests/test_minres.py +97 -0
- scipy/sparse/linalg/_isolve/tests/test_utils.py +9 -0
- scipy/sparse/linalg/_isolve/tfqmr.py +179 -0
- scipy/sparse/linalg/_isolve/utils.py +121 -0
- scipy/sparse/linalg/_matfuncs.py +940 -0
- scipy/sparse/linalg/_norm.py +195 -0
- scipy/sparse/linalg/_onenormest.py +467 -0
- scipy/sparse/linalg/_propack/_cpropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_special_sparse_arrays.py +949 -0
- scipy/sparse/linalg/_svdp.py +309 -0
- scipy/sparse/linalg/dsolve.py +22 -0
- scipy/sparse/linalg/eigen.py +21 -0
- scipy/sparse/linalg/interface.py +20 -0
- scipy/sparse/linalg/isolve.py +22 -0
- scipy/sparse/linalg/matfuncs.py +18 -0
- scipy/sparse/linalg/tests/__init__.py +0 -0
- scipy/sparse/linalg/tests/propack_test_data.npz +0 -0
- scipy/sparse/linalg/tests/test_expm_multiply.py +367 -0
- scipy/sparse/linalg/tests/test_interface.py +561 -0
- scipy/sparse/linalg/tests/test_matfuncs.py +592 -0
- scipy/sparse/linalg/tests/test_norm.py +154 -0
- scipy/sparse/linalg/tests/test_onenormest.py +252 -0
- scipy/sparse/linalg/tests/test_propack.py +165 -0
- scipy/sparse/linalg/tests/test_pydata_sparse.py +272 -0
- scipy/sparse/linalg/tests/test_special_sparse_arrays.py +337 -0
- scipy/sparse/sparsetools.py +17 -0
- scipy/sparse/spfuncs.py +17 -0
- scipy/sparse/sputils.py +17 -0
- scipy/sparse/tests/__init__.py +0 -0
- scipy/sparse/tests/data/csc_py2.npz +0 -0
- scipy/sparse/tests/data/csc_py3.npz +0 -0
- scipy/sparse/tests/test_arithmetic1d.py +341 -0
- scipy/sparse/tests/test_array_api.py +561 -0
- scipy/sparse/tests/test_base.py +5870 -0
- scipy/sparse/tests/test_common1d.py +447 -0
- scipy/sparse/tests/test_construct.py +872 -0
- scipy/sparse/tests/test_coo.py +1119 -0
- scipy/sparse/tests/test_csc.py +98 -0
- scipy/sparse/tests/test_csr.py +214 -0
- scipy/sparse/tests/test_dok.py +209 -0
- scipy/sparse/tests/test_extract.py +51 -0
- scipy/sparse/tests/test_indexing1d.py +603 -0
- scipy/sparse/tests/test_matrix_io.py +109 -0
- scipy/sparse/tests/test_minmax1d.py +128 -0
- scipy/sparse/tests/test_sparsetools.py +344 -0
- scipy/sparse/tests/test_spfuncs.py +97 -0
- scipy/sparse/tests/test_sputils.py +424 -0
- scipy/spatial/__init__.py +129 -0
- scipy/spatial/_ckdtree.cp314-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp314-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp314-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp314-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_kdtree.py +920 -0
- scipy/spatial/_plotutils.py +274 -0
- scipy/spatial/_procrustes.py +132 -0
- scipy/spatial/_qhull.cp314-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp314-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_voronoi.pyi +4 -0
- scipy/spatial/ckdtree.py +18 -0
- scipy/spatial/distance.py +3147 -0
- scipy/spatial/distance.pyi +210 -0
- scipy/spatial/kdtree.py +25 -0
- scipy/spatial/qhull.py +25 -0
- scipy/spatial/qhull_src/COPYING_QHULL.txt +39 -0
- scipy/spatial/tests/__init__.py +0 -0
- scipy/spatial/tests/data/cdist-X1.txt +10 -0
- scipy/spatial/tests/data/cdist-X2.txt +20 -0
- scipy/spatial/tests/data/degenerate_pointset.npz +0 -0
- scipy/spatial/tests/data/iris.txt +150 -0
- scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
- scipy/spatial/tests/data/random-bool-data.txt +100 -0
- scipy/spatial/tests/data/random-double-data.txt +100 -0
- scipy/spatial/tests/data/random-int-data.txt +100 -0
- scipy/spatial/tests/data/random-uint-data.txt +100 -0
- scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
- scipy/spatial/tests/test__plotutils.py +91 -0
- scipy/spatial/tests/test__procrustes.py +116 -0
- scipy/spatial/tests/test_distance.py +2389 -0
- scipy/spatial/tests/test_hausdorff.py +199 -0
- scipy/spatial/tests/test_kdtree.py +1536 -0
- scipy/spatial/tests/test_qhull.py +1313 -0
- scipy/spatial/tests/test_slerp.py +417 -0
- scipy/spatial/tests/test_spherical_voronoi.py +358 -0
- scipy/spatial/transform/__init__.py +31 -0
- scipy/spatial/transform/_rigid_transform.cp314-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp314-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp314-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp314-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation_groups.py +140 -0
- scipy/spatial/transform/_rotation_spline.py +460 -0
- scipy/spatial/transform/rotation.py +21 -0
- scipy/spatial/transform/tests/__init__.py +0 -0
- scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
- scipy/spatial/transform/tests/test_rotation.py +2569 -0
- scipy/spatial/transform/tests/test_rotation_groups.py +169 -0
- scipy/spatial/transform/tests/test_rotation_spline.py +183 -0
- scipy/special/__init__.pxd +1 -0
- scipy/special/__init__.py +841 -0
- scipy/special/_add_newdocs.py +9961 -0
- scipy/special/_basic.py +3576 -0
- scipy/special/_comb.cp314-win_arm64.lib +0 -0
- scipy/special/_comb.cp314-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp314-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp314-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp314-win_arm64.pyd +0 -0
- scipy/special/_input_validation.py +17 -0
- scipy/special/_lambertw.py +149 -0
- scipy/special/_logsumexp.py +426 -0
- scipy/special/_mptestutils.py +453 -0
- scipy/special/_multiufuncs.py +610 -0
- scipy/special/_orthogonal.py +2592 -0
- scipy/special/_orthogonal.pyi +330 -0
- scipy/special/_precompute/__init__.py +0 -0
- scipy/special/_precompute/cosine_cdf.py +17 -0
- scipy/special/_precompute/expn_asy.py +54 -0
- scipy/special/_precompute/gammainc_asy.py +116 -0
- scipy/special/_precompute/gammainc_data.py +124 -0
- scipy/special/_precompute/hyp2f1_data.py +484 -0
- scipy/special/_precompute/lambertw.py +68 -0
- scipy/special/_precompute/loggamma.py +43 -0
- scipy/special/_precompute/struve_convergence.py +131 -0
- scipy/special/_precompute/utils.py +38 -0
- scipy/special/_precompute/wright_bessel.py +342 -0
- scipy/special/_precompute/wright_bessel_data.py +152 -0
- scipy/special/_precompute/wrightomega.py +41 -0
- scipy/special/_precompute/zetac.py +27 -0
- scipy/special/_sf_error.py +15 -0
- scipy/special/_specfun.cp314-win_arm64.lib +0 -0
- scipy/special/_specfun.cp314-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp314-win_arm64.pyd +0 -0
- scipy/special/_spfun_stats.py +106 -0
- scipy/special/_spherical_bessel.py +397 -0
- scipy/special/_support_alternative_backends.py +295 -0
- scipy/special/_test_internal.cp314-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp314-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp314-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp314-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp314-win_arm64.pyd +0 -0
- scipy/special/_ufuncs_cxx.pxd +142 -0
- scipy/special/_ufuncs_cxx.pyx +427 -0
- scipy/special/_ufuncs_cxx_defs.h +147 -0
- scipy/special/_ufuncs_defs.h +57 -0
- scipy/special/add_newdocs.py +15 -0
- scipy/special/basic.py +87 -0
- scipy/special/cython_special.cp314-win_arm64.lib +0 -0
- scipy/special/cython_special.cp314-win_arm64.pyd +0 -0
- scipy/special/cython_special.pxd +259 -0
- scipy/special/cython_special.pyi +3 -0
- scipy/special/orthogonal.py +45 -0
- scipy/special/sf_error.py +20 -0
- scipy/special/specfun.py +24 -0
- scipy/special/spfun_stats.py +17 -0
- scipy/special/tests/__init__.py +0 -0
- scipy/special/tests/_cython_examples/extending.pyx +12 -0
- scipy/special/tests/_cython_examples/meson.build +34 -0
- scipy/special/tests/data/__init__.py +0 -0
- scipy/special/tests/data/boost.npz +0 -0
- scipy/special/tests/data/gsl.npz +0 -0
- scipy/special/tests/data/local.npz +0 -0
- scipy/special/tests/test_basic.py +4815 -0
- scipy/special/tests/test_bdtr.py +112 -0
- scipy/special/tests/test_boost_ufuncs.py +64 -0
- scipy/special/tests/test_boxcox.py +125 -0
- scipy/special/tests/test_cdflib.py +712 -0
- scipy/special/tests/test_cdft_asymptotic.py +49 -0
- scipy/special/tests/test_cephes_intp_cast.py +29 -0
- scipy/special/tests/test_cosine_distr.py +83 -0
- scipy/special/tests/test_cython_special.py +363 -0
- scipy/special/tests/test_data.py +719 -0
- scipy/special/tests/test_dd.py +42 -0
- scipy/special/tests/test_digamma.py +45 -0
- scipy/special/tests/test_ellip_harm.py +278 -0
- scipy/special/tests/test_erfinv.py +89 -0
- scipy/special/tests/test_exponential_integrals.py +118 -0
- scipy/special/tests/test_extending.py +28 -0
- scipy/special/tests/test_faddeeva.py +85 -0
- scipy/special/tests/test_gamma.py +12 -0
- scipy/special/tests/test_gammainc.py +152 -0
- scipy/special/tests/test_hyp2f1.py +2566 -0
- scipy/special/tests/test_hypergeometric.py +234 -0
- scipy/special/tests/test_iv_ratio.py +249 -0
- scipy/special/tests/test_kolmogorov.py +491 -0
- scipy/special/tests/test_lambertw.py +109 -0
- scipy/special/tests/test_legendre.py +1518 -0
- scipy/special/tests/test_log1mexp.py +85 -0
- scipy/special/tests/test_loggamma.py +70 -0
- scipy/special/tests/test_logit.py +162 -0
- scipy/special/tests/test_logsumexp.py +469 -0
- scipy/special/tests/test_mpmath.py +2293 -0
- scipy/special/tests/test_nan_inputs.py +65 -0
- scipy/special/tests/test_ndtr.py +77 -0
- scipy/special/tests/test_ndtri_exp.py +94 -0
- scipy/special/tests/test_orthogonal.py +821 -0
- scipy/special/tests/test_orthogonal_eval.py +275 -0
- scipy/special/tests/test_owens_t.py +53 -0
- scipy/special/tests/test_pcf.py +24 -0
- scipy/special/tests/test_pdtr.py +48 -0
- scipy/special/tests/test_powm1.py +65 -0
- scipy/special/tests/test_precompute_expn_asy.py +24 -0
- scipy/special/tests/test_precompute_gammainc.py +108 -0
- scipy/special/tests/test_precompute_utils.py +36 -0
- scipy/special/tests/test_round.py +18 -0
- scipy/special/tests/test_sf_error.py +146 -0
- scipy/special/tests/test_sici.py +36 -0
- scipy/special/tests/test_specfun.py +48 -0
- scipy/special/tests/test_spence.py +32 -0
- scipy/special/tests/test_spfun_stats.py +61 -0
- scipy/special/tests/test_sph_harm.py +85 -0
- scipy/special/tests/test_spherical_bessel.py +400 -0
- scipy/special/tests/test_support_alternative_backends.py +248 -0
- scipy/special/tests/test_trig.py +72 -0
- scipy/special/tests/test_ufunc_signatures.py +46 -0
- scipy/special/tests/test_wright_bessel.py +205 -0
- scipy/special/tests/test_wrightomega.py +117 -0
- scipy/special/tests/test_zeta.py +301 -0
- scipy/stats/__init__.py +670 -0
- scipy/stats/_ansari_swilk_statistics.cp314-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp314-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp314-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp314-win_arm64.pyd +0 -0
- scipy/stats/_biasedurn.pxd +27 -0
- scipy/stats/_binned_statistic.py +795 -0
- scipy/stats/_binomtest.py +375 -0
- scipy/stats/_bws_test.py +177 -0
- scipy/stats/_censored_data.py +459 -0
- scipy/stats/_common.py +5 -0
- scipy/stats/_constants.py +42 -0
- scipy/stats/_continued_fraction.py +387 -0
- scipy/stats/_continuous_distns.py +12486 -0
- scipy/stats/_correlation.py +210 -0
- scipy/stats/_covariance.py +636 -0
- scipy/stats/_crosstab.py +204 -0
- scipy/stats/_discrete_distns.py +2098 -0
- scipy/stats/_distn_infrastructure.py +4201 -0
- scipy/stats/_distr_params.py +299 -0
- scipy/stats/_distribution_infrastructure.py +5750 -0
- scipy/stats/_entropy.py +428 -0
- scipy/stats/_finite_differences.py +145 -0
- scipy/stats/_fit.py +1351 -0
- scipy/stats/_hypotests.py +2060 -0
- scipy/stats/_kde.py +732 -0
- scipy/stats/_ksstats.py +600 -0
- scipy/stats/_levy_stable/__init__.py +1231 -0
- scipy/stats/_levy_stable/levyst.cp314-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp314-win_arm64.pyd +0 -0
- scipy/stats/_mannwhitneyu.py +492 -0
- scipy/stats/_mgc.py +550 -0
- scipy/stats/_morestats.py +4626 -0
- scipy/stats/_mstats_basic.py +3658 -0
- scipy/stats/_mstats_extras.py +521 -0
- scipy/stats/_multicomp.py +449 -0
- scipy/stats/_multivariate.py +7281 -0
- scipy/stats/_new_distributions.py +452 -0
- scipy/stats/_odds_ratio.py +466 -0
- scipy/stats/_page_trend_test.py +486 -0
- scipy/stats/_probability_distribution.py +1964 -0
- scipy/stats/_qmc.py +2956 -0
- scipy/stats/_qmc_cy.cp314-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp314-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp314-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp314-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp314-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp314-win_arm64.pyd +0 -0
- scipy/stats/_relative_risk.py +263 -0
- scipy/stats/_resampling.py +2352 -0
- scipy/stats/_result_classes.py +40 -0
- scipy/stats/_sampling.py +1314 -0
- scipy/stats/_sensitivity_analysis.py +713 -0
- scipy/stats/_sobol.cp314-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp314-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp314-win_arm64.lib +0 -0
- scipy/stats/_stats.cp314-win_arm64.pyd +0 -0
- scipy/stats/_stats.pxd +10 -0
- scipy/stats/_stats_mstats_common.py +322 -0
- scipy/stats/_stats_py.py +11089 -0
- scipy/stats/_stats_pythran.cp314-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp314-win_arm64.pyd +0 -0
- scipy/stats/_survival.py +683 -0
- scipy/stats/_tukeylambda_stats.py +199 -0
- scipy/stats/_unuran/__init__.py +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp314-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp314-win_arm64.pyd +0 -0
- scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
- scipy/stats/_variation.py +126 -0
- scipy/stats/_warnings_errors.py +38 -0
- scipy/stats/_wilcoxon.py +265 -0
- scipy/stats/biasedurn.py +16 -0
- scipy/stats/contingency.py +521 -0
- scipy/stats/distributions.py +24 -0
- scipy/stats/kde.py +18 -0
- scipy/stats/morestats.py +27 -0
- scipy/stats/mstats.py +140 -0
- scipy/stats/mstats_basic.py +42 -0
- scipy/stats/mstats_extras.py +25 -0
- scipy/stats/mvn.py +17 -0
- scipy/stats/qmc.py +236 -0
- scipy/stats/sampling.py +73 -0
- scipy/stats/stats.py +41 -0
- scipy/stats/tests/__init__.py +0 -0
- scipy/stats/tests/common_tests.py +356 -0
- scipy/stats/tests/data/_mvt.py +171 -0
- scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
- scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
- scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
- scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
- scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
- scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
- scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
- scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
- scipy/stats/tests/test_axis_nan_policy.py +1388 -0
- scipy/stats/tests/test_binned_statistic.py +568 -0
- scipy/stats/tests/test_censored_data.py +152 -0
- scipy/stats/tests/test_contingency.py +294 -0
- scipy/stats/tests/test_continued_fraction.py +173 -0
- scipy/stats/tests/test_continuous.py +2198 -0
- scipy/stats/tests/test_continuous_basic.py +1053 -0
- scipy/stats/tests/test_continuous_fit_censored.py +683 -0
- scipy/stats/tests/test_correlation.py +80 -0
- scipy/stats/tests/test_crosstab.py +115 -0
- scipy/stats/tests/test_discrete_basic.py +580 -0
- scipy/stats/tests/test_discrete_distns.py +700 -0
- scipy/stats/tests/test_distributions.py +10413 -0
- scipy/stats/tests/test_entropy.py +322 -0
- scipy/stats/tests/test_fast_gen_inversion.py +435 -0
- scipy/stats/tests/test_fit.py +1090 -0
- scipy/stats/tests/test_hypotests.py +1991 -0
- scipy/stats/tests/test_kdeoth.py +676 -0
- scipy/stats/tests/test_marray.py +289 -0
- scipy/stats/tests/test_mgc.py +217 -0
- scipy/stats/tests/test_morestats.py +3259 -0
- scipy/stats/tests/test_mstats_basic.py +2071 -0
- scipy/stats/tests/test_mstats_extras.py +172 -0
- scipy/stats/tests/test_multicomp.py +405 -0
- scipy/stats/tests/test_multivariate.py +4381 -0
- scipy/stats/tests/test_odds_ratio.py +148 -0
- scipy/stats/tests/test_qmc.py +1492 -0
- scipy/stats/tests/test_quantile.py +199 -0
- scipy/stats/tests/test_rank.py +345 -0
- scipy/stats/tests/test_relative_risk.py +95 -0
- scipy/stats/tests/test_resampling.py +2000 -0
- scipy/stats/tests/test_sampling.py +1450 -0
- scipy/stats/tests/test_sensitivity_analysis.py +310 -0
- scipy/stats/tests/test_stats.py +9707 -0
- scipy/stats/tests/test_survival.py +466 -0
- scipy/stats/tests/test_tukeylambda_stats.py +85 -0
- scipy/stats/tests/test_variation.py +216 -0
- scipy/version.py +12 -0
- scipy-1.16.2.dist-info/DELVEWHEEL +2 -0
- scipy-1.16.2.dist-info/LICENSE.txt +912 -0
- scipy-1.16.2.dist-info/METADATA +1061 -0
- scipy-1.16.2.dist-info/RECORD +1530 -0
- scipy-1.16.2.dist-info/WHEEL +4 -0
- scipy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
- scipy.libs/scipy_openblas-f3ac85b1f412f7e86514c923dc4058d1.dll +0 -0
@@ -0,0 +1,2634 @@
|
|
1
|
+
# Copyright (C) 2003-2005 Peter J. Verveer
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions
|
5
|
+
# are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# 2. Redistributions in binary form must reproduce the above
|
11
|
+
# copyright notice, this list of conditions and the following
|
12
|
+
# disclaimer in the documentation and/or other materials provided
|
13
|
+
# with the distribution.
|
14
|
+
#
|
15
|
+
# 3. The name of the author may not be used to endorse or promote
|
16
|
+
# products derived from this software without specific prior
|
17
|
+
# written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
20
|
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
23
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
25
|
+
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
27
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
import warnings
|
32
|
+
import operator
|
33
|
+
|
34
|
+
import numpy as np
|
35
|
+
from . import _ni_support
|
36
|
+
from . import _nd_image
|
37
|
+
from . import _filters
|
38
|
+
|
39
|
+
__all__ = ['iterate_structure', 'generate_binary_structure', 'binary_erosion',
|
40
|
+
'binary_dilation', 'binary_opening', 'binary_closing',
|
41
|
+
'binary_hit_or_miss', 'binary_propagation', 'binary_fill_holes',
|
42
|
+
'grey_erosion', 'grey_dilation', 'grey_opening', 'grey_closing',
|
43
|
+
'morphological_gradient', 'morphological_laplace', 'white_tophat',
|
44
|
+
'black_tophat', 'distance_transform_bf', 'distance_transform_cdt',
|
45
|
+
'distance_transform_edt']
|
46
|
+
|
47
|
+
|
48
|
+
def _center_is_true(structure, origin):
|
49
|
+
structure = np.asarray(structure)
|
50
|
+
coor = tuple([oo + ss // 2 for ss, oo in zip(structure.shape,
|
51
|
+
origin)])
|
52
|
+
return bool(structure[coor])
|
53
|
+
|
54
|
+
|
55
|
+
def iterate_structure(structure, iterations, origin=None):
|
56
|
+
"""
|
57
|
+
Iterate a structure by dilating it with itself.
|
58
|
+
|
59
|
+
Parameters
|
60
|
+
----------
|
61
|
+
structure : array_like
|
62
|
+
Structuring element (an array of bools, for example), to be dilated with
|
63
|
+
itself.
|
64
|
+
iterations : int
|
65
|
+
number of dilations performed on the structure with itself
|
66
|
+
origin : optional
|
67
|
+
If origin is None, only the iterated structure is returned. If
|
68
|
+
not, a tuple of the iterated structure and the modified origin is
|
69
|
+
returned.
|
70
|
+
|
71
|
+
Returns
|
72
|
+
-------
|
73
|
+
iterate_structure : ndarray of bools
|
74
|
+
A new structuring element obtained by dilating `structure`
|
75
|
+
(`iterations` - 1) times with itself.
|
76
|
+
|
77
|
+
See Also
|
78
|
+
--------
|
79
|
+
generate_binary_structure
|
80
|
+
|
81
|
+
Examples
|
82
|
+
--------
|
83
|
+
>>> from scipy import ndimage
|
84
|
+
>>> struct = ndimage.generate_binary_structure(2, 1)
|
85
|
+
>>> struct.astype(int)
|
86
|
+
array([[0, 1, 0],
|
87
|
+
[1, 1, 1],
|
88
|
+
[0, 1, 0]])
|
89
|
+
>>> ndimage.iterate_structure(struct, 2).astype(int)
|
90
|
+
array([[0, 0, 1, 0, 0],
|
91
|
+
[0, 1, 1, 1, 0],
|
92
|
+
[1, 1, 1, 1, 1],
|
93
|
+
[0, 1, 1, 1, 0],
|
94
|
+
[0, 0, 1, 0, 0]])
|
95
|
+
>>> ndimage.iterate_structure(struct, 3).astype(int)
|
96
|
+
array([[0, 0, 0, 1, 0, 0, 0],
|
97
|
+
[0, 0, 1, 1, 1, 0, 0],
|
98
|
+
[0, 1, 1, 1, 1, 1, 0],
|
99
|
+
[1, 1, 1, 1, 1, 1, 1],
|
100
|
+
[0, 1, 1, 1, 1, 1, 0],
|
101
|
+
[0, 0, 1, 1, 1, 0, 0],
|
102
|
+
[0, 0, 0, 1, 0, 0, 0]])
|
103
|
+
|
104
|
+
"""
|
105
|
+
structure = np.asarray(structure)
|
106
|
+
if iterations < 2:
|
107
|
+
return structure.copy()
|
108
|
+
ni = iterations - 1
|
109
|
+
shape = [ii + ni * (ii - 1) for ii in structure.shape]
|
110
|
+
pos = [ni * (structure.shape[ii] // 2) for ii in range(len(shape))]
|
111
|
+
slc = tuple(slice(pos[ii], pos[ii] + structure.shape[ii], None)
|
112
|
+
for ii in range(len(shape)))
|
113
|
+
out = np.zeros(shape, bool)
|
114
|
+
out[slc] = structure != 0
|
115
|
+
out = binary_dilation(out, structure, iterations=ni)
|
116
|
+
if origin is None:
|
117
|
+
return out
|
118
|
+
else:
|
119
|
+
origin = _ni_support._normalize_sequence(origin, structure.ndim)
|
120
|
+
origin = [iterations * o for o in origin]
|
121
|
+
return out, origin
|
122
|
+
|
123
|
+
|
124
|
+
def generate_binary_structure(rank, connectivity):
|
125
|
+
"""
|
126
|
+
Generate a binary structure for binary morphological operations.
|
127
|
+
|
128
|
+
Parameters
|
129
|
+
----------
|
130
|
+
rank : int
|
131
|
+
Number of dimensions of the array to which the structuring element
|
132
|
+
will be applied, as returned by `np.ndim`.
|
133
|
+
connectivity : int
|
134
|
+
`connectivity` determines which elements of the output array belong
|
135
|
+
to the structure, i.e., are considered as neighbors of the central
|
136
|
+
element. Elements up to a squared distance of `connectivity` from
|
137
|
+
the center are considered neighbors. `connectivity` may range from 1
|
138
|
+
(no diagonal elements are neighbors) to `rank` (all elements are
|
139
|
+
neighbors).
|
140
|
+
|
141
|
+
Returns
|
142
|
+
-------
|
143
|
+
output : ndarray of bools
|
144
|
+
Structuring element which may be used for binary morphological
|
145
|
+
operations, with `rank` dimensions and all dimensions equal to 3.
|
146
|
+
|
147
|
+
See Also
|
148
|
+
--------
|
149
|
+
iterate_structure, binary_dilation, binary_erosion
|
150
|
+
|
151
|
+
Notes
|
152
|
+
-----
|
153
|
+
`generate_binary_structure` can only create structuring elements with
|
154
|
+
dimensions equal to 3, i.e., minimal dimensions. For larger structuring
|
155
|
+
elements, that are useful e.g., for eroding large objects, one may either
|
156
|
+
use `iterate_structure`, or create directly custom arrays with
|
157
|
+
numpy functions such as `numpy.ones`.
|
158
|
+
|
159
|
+
Examples
|
160
|
+
--------
|
161
|
+
>>> from scipy import ndimage
|
162
|
+
>>> import numpy as np
|
163
|
+
>>> struct = ndimage.generate_binary_structure(2, 1)
|
164
|
+
>>> struct
|
165
|
+
array([[False, True, False],
|
166
|
+
[ True, True, True],
|
167
|
+
[False, True, False]], dtype=bool)
|
168
|
+
>>> a = np.zeros((5,5))
|
169
|
+
>>> a[2, 2] = 1
|
170
|
+
>>> a
|
171
|
+
array([[ 0., 0., 0., 0., 0.],
|
172
|
+
[ 0., 0., 0., 0., 0.],
|
173
|
+
[ 0., 0., 1., 0., 0.],
|
174
|
+
[ 0., 0., 0., 0., 0.],
|
175
|
+
[ 0., 0., 0., 0., 0.]])
|
176
|
+
>>> b = ndimage.binary_dilation(a, structure=struct).astype(a.dtype)
|
177
|
+
>>> b
|
178
|
+
array([[ 0., 0., 0., 0., 0.],
|
179
|
+
[ 0., 0., 1., 0., 0.],
|
180
|
+
[ 0., 1., 1., 1., 0.],
|
181
|
+
[ 0., 0., 1., 0., 0.],
|
182
|
+
[ 0., 0., 0., 0., 0.]])
|
183
|
+
>>> ndimage.binary_dilation(b, structure=struct).astype(a.dtype)
|
184
|
+
array([[ 0., 0., 1., 0., 0.],
|
185
|
+
[ 0., 1., 1., 1., 0.],
|
186
|
+
[ 1., 1., 1., 1., 1.],
|
187
|
+
[ 0., 1., 1., 1., 0.],
|
188
|
+
[ 0., 0., 1., 0., 0.]])
|
189
|
+
>>> struct = ndimage.generate_binary_structure(2, 2)
|
190
|
+
>>> struct
|
191
|
+
array([[ True, True, True],
|
192
|
+
[ True, True, True],
|
193
|
+
[ True, True, True]], dtype=bool)
|
194
|
+
>>> struct = ndimage.generate_binary_structure(3, 1)
|
195
|
+
>>> struct # no diagonal elements
|
196
|
+
array([[[False, False, False],
|
197
|
+
[False, True, False],
|
198
|
+
[False, False, False]],
|
199
|
+
[[False, True, False],
|
200
|
+
[ True, True, True],
|
201
|
+
[False, True, False]],
|
202
|
+
[[False, False, False],
|
203
|
+
[False, True, False],
|
204
|
+
[False, False, False]]], dtype=bool)
|
205
|
+
|
206
|
+
"""
|
207
|
+
if connectivity < 1:
|
208
|
+
connectivity = 1
|
209
|
+
if rank < 1:
|
210
|
+
return np.array(True, dtype=bool)
|
211
|
+
output = np.fabs(np.indices([3] * rank) - 1)
|
212
|
+
output = np.add.reduce(output, 0)
|
213
|
+
return output <= connectivity
|
214
|
+
|
215
|
+
|
216
|
+
def _binary_erosion(input, structure, iterations, mask, output,
|
217
|
+
border_value, origin, invert, brute_force, axes):
|
218
|
+
try:
|
219
|
+
iterations = operator.index(iterations)
|
220
|
+
except TypeError as e:
|
221
|
+
raise TypeError('iterations parameter should be an integer') from e
|
222
|
+
|
223
|
+
input = np.asarray(input)
|
224
|
+
# The Cython code can't cope with broadcasted inputs
|
225
|
+
if not input.flags.c_contiguous and not input.flags.f_contiguous:
|
226
|
+
input = np.ascontiguousarray(input)
|
227
|
+
|
228
|
+
ndim = input.ndim
|
229
|
+
if np.iscomplexobj(input):
|
230
|
+
raise TypeError('Complex type not supported')
|
231
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
232
|
+
num_axes = len(axes)
|
233
|
+
if structure is None:
|
234
|
+
structure = generate_binary_structure(num_axes, 1)
|
235
|
+
else:
|
236
|
+
structure = np.asarray(structure, dtype=bool)
|
237
|
+
if ndim > num_axes:
|
238
|
+
structure = _filters._expand_footprint(ndim, axes, structure,
|
239
|
+
footprint_name="structure")
|
240
|
+
|
241
|
+
if structure.ndim != input.ndim:
|
242
|
+
raise RuntimeError('structure and input must have same dimensionality')
|
243
|
+
if not structure.flags.contiguous:
|
244
|
+
structure = structure.copy()
|
245
|
+
if structure.size < 1:
|
246
|
+
raise RuntimeError('structure must not be empty')
|
247
|
+
if mask is not None:
|
248
|
+
mask = np.asarray(mask)
|
249
|
+
if mask.shape != input.shape:
|
250
|
+
raise RuntimeError('mask and input must have equal sizes')
|
251
|
+
origin = _ni_support._normalize_sequence(origin, num_axes)
|
252
|
+
origin = _filters._expand_origin(ndim, axes, origin)
|
253
|
+
cit = _center_is_true(structure, origin)
|
254
|
+
if isinstance(output, np.ndarray):
|
255
|
+
if np.iscomplexobj(output):
|
256
|
+
raise TypeError('Complex output type not supported')
|
257
|
+
else:
|
258
|
+
output = bool
|
259
|
+
output = _ni_support._get_output(output, input)
|
260
|
+
temp_needed = np.may_share_memory(input, output)
|
261
|
+
if temp_needed:
|
262
|
+
# input and output arrays cannot share memory
|
263
|
+
temp = output
|
264
|
+
output = _ni_support._get_output(output.dtype, input)
|
265
|
+
if iterations == 1:
|
266
|
+
_nd_image.binary_erosion(input, structure, mask, output,
|
267
|
+
border_value, origin, invert, cit, 0)
|
268
|
+
elif cit and not brute_force:
|
269
|
+
changed, coordinate_list = _nd_image.binary_erosion(
|
270
|
+
input, structure, mask, output,
|
271
|
+
border_value, origin, invert, cit, 1)
|
272
|
+
structure = structure[tuple([slice(None, None, -1)] *
|
273
|
+
structure.ndim)]
|
274
|
+
for ii in range(len(origin)):
|
275
|
+
origin[ii] = -origin[ii]
|
276
|
+
if not structure.shape[ii] & 1:
|
277
|
+
origin[ii] -= 1
|
278
|
+
if mask is not None:
|
279
|
+
mask = np.asarray(mask, dtype=np.int8)
|
280
|
+
if not structure.flags.contiguous:
|
281
|
+
structure = structure.copy()
|
282
|
+
_nd_image.binary_erosion2(output, structure, mask, iterations - 1,
|
283
|
+
origin, invert, coordinate_list)
|
284
|
+
else:
|
285
|
+
tmp_in = np.empty_like(input, dtype=bool)
|
286
|
+
tmp_out = output
|
287
|
+
if iterations >= 1 and not iterations & 1:
|
288
|
+
tmp_in, tmp_out = tmp_out, tmp_in
|
289
|
+
changed = _nd_image.binary_erosion(
|
290
|
+
input, structure, mask, tmp_out,
|
291
|
+
border_value, origin, invert, cit, 0)
|
292
|
+
ii = 1
|
293
|
+
while ii < iterations or (iterations < 1 and changed):
|
294
|
+
tmp_in, tmp_out = tmp_out, tmp_in
|
295
|
+
changed = _nd_image.binary_erosion(
|
296
|
+
tmp_in, structure, mask, tmp_out,
|
297
|
+
border_value, origin, invert, cit, 0)
|
298
|
+
ii += 1
|
299
|
+
if temp_needed:
|
300
|
+
temp[...] = output
|
301
|
+
output = temp
|
302
|
+
return output
|
303
|
+
|
304
|
+
|
305
|
+
def binary_erosion(input, structure=None, iterations=1, mask=None, output=None,
|
306
|
+
border_value=0, origin=0, brute_force=False, *, axes=None):
|
307
|
+
"""
|
308
|
+
Multidimensional binary erosion with a given structuring element.
|
309
|
+
|
310
|
+
Binary erosion is a mathematical morphology operation used for image
|
311
|
+
processing.
|
312
|
+
|
313
|
+
Parameters
|
314
|
+
----------
|
315
|
+
input : array_like
|
316
|
+
Binary image to be eroded. Non-zero (True) elements form
|
317
|
+
the subset to be eroded.
|
318
|
+
structure : array_like, optional
|
319
|
+
Structuring element used for the erosion. Non-zero elements are
|
320
|
+
considered True. If no structuring element is provided, an element
|
321
|
+
is generated with a square connectivity equal to one.
|
322
|
+
iterations : int, optional
|
323
|
+
The erosion is repeated `iterations` times (one, by default).
|
324
|
+
If iterations is less than 1, the erosion is repeated until the
|
325
|
+
result does not change anymore.
|
326
|
+
mask : array_like, optional
|
327
|
+
If a mask is given, only those elements with a True value at
|
328
|
+
the corresponding mask element are modified at each iteration.
|
329
|
+
output : ndarray, optional
|
330
|
+
Array of the same shape as input, into which the output is placed.
|
331
|
+
By default, a new array is created.
|
332
|
+
border_value : int (cast to 0 or 1), optional
|
333
|
+
Value at the border in the output array.
|
334
|
+
origin : int or tuple of ints, optional
|
335
|
+
Placement of the filter, by default 0.
|
336
|
+
brute_force : boolean, optional
|
337
|
+
Memory condition: if False, only the pixels whose value was changed in
|
338
|
+
the last iteration are tracked as candidates to be updated (eroded) in
|
339
|
+
the current iteration; if True all pixels are considered as candidates
|
340
|
+
for erosion, regardless of what happened in the previous iteration.
|
341
|
+
False by default.
|
342
|
+
axes : tuple of int or None
|
343
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
344
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
345
|
+
the number of axes.
|
346
|
+
|
347
|
+
Returns
|
348
|
+
-------
|
349
|
+
binary_erosion : ndarray of bools
|
350
|
+
Erosion of the input by the structuring element.
|
351
|
+
|
352
|
+
See Also
|
353
|
+
--------
|
354
|
+
grey_erosion, binary_dilation, binary_closing, binary_opening,
|
355
|
+
generate_binary_structure
|
356
|
+
|
357
|
+
Notes
|
358
|
+
-----
|
359
|
+
Erosion [1]_ is a mathematical morphology operation [2]_ that uses a
|
360
|
+
structuring element for shrinking the shapes in an image. The binary
|
361
|
+
erosion of an image by a structuring element is the locus of the points
|
362
|
+
where a superimposition of the structuring element centered on the point
|
363
|
+
is entirely contained in the set of non-zero elements of the image.
|
364
|
+
|
365
|
+
References
|
366
|
+
----------
|
367
|
+
.. [1] https://en.wikipedia.org/wiki/Erosion_%28morphology%29
|
368
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
369
|
+
|
370
|
+
Examples
|
371
|
+
--------
|
372
|
+
>>> from scipy import ndimage
|
373
|
+
>>> import numpy as np
|
374
|
+
>>> a = np.zeros((7,7), dtype=int)
|
375
|
+
>>> a[1:6, 2:5] = 1
|
376
|
+
>>> a
|
377
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
378
|
+
[0, 0, 1, 1, 1, 0, 0],
|
379
|
+
[0, 0, 1, 1, 1, 0, 0],
|
380
|
+
[0, 0, 1, 1, 1, 0, 0],
|
381
|
+
[0, 0, 1, 1, 1, 0, 0],
|
382
|
+
[0, 0, 1, 1, 1, 0, 0],
|
383
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
384
|
+
>>> ndimage.binary_erosion(a).astype(a.dtype)
|
385
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
386
|
+
[0, 0, 0, 0, 0, 0, 0],
|
387
|
+
[0, 0, 0, 1, 0, 0, 0],
|
388
|
+
[0, 0, 0, 1, 0, 0, 0],
|
389
|
+
[0, 0, 0, 1, 0, 0, 0],
|
390
|
+
[0, 0, 0, 0, 0, 0, 0],
|
391
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
392
|
+
>>> #Erosion removes objects smaller than the structure
|
393
|
+
>>> ndimage.binary_erosion(a, structure=np.ones((5,5))).astype(a.dtype)
|
394
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
395
|
+
[0, 0, 0, 0, 0, 0, 0],
|
396
|
+
[0, 0, 0, 0, 0, 0, 0],
|
397
|
+
[0, 0, 0, 0, 0, 0, 0],
|
398
|
+
[0, 0, 0, 0, 0, 0, 0],
|
399
|
+
[0, 0, 0, 0, 0, 0, 0],
|
400
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
401
|
+
|
402
|
+
"""
|
403
|
+
return _binary_erosion(input, structure, iterations, mask,
|
404
|
+
output, border_value, origin, 0, brute_force, axes)
|
405
|
+
|
406
|
+
|
407
|
+
def binary_dilation(input, structure=None, iterations=1, mask=None,
|
408
|
+
output=None, border_value=0, origin=0,
|
409
|
+
brute_force=False, *, axes=None):
|
410
|
+
"""
|
411
|
+
Multidimensional binary dilation with the given structuring element.
|
412
|
+
|
413
|
+
Parameters
|
414
|
+
----------
|
415
|
+
input : array_like
|
416
|
+
Binary array_like to be dilated. Non-zero (True) elements form
|
417
|
+
the subset to be dilated.
|
418
|
+
structure : array_like, optional
|
419
|
+
Structuring element used for the dilation. Non-zero elements are
|
420
|
+
considered True. If no structuring element is provided an element
|
421
|
+
is generated with a square connectivity equal to one.
|
422
|
+
iterations : int, optional
|
423
|
+
The dilation is repeated `iterations` times (one, by default).
|
424
|
+
If iterations is less than 1, the dilation is repeated until the
|
425
|
+
result does not change anymore. Only an integer of iterations is
|
426
|
+
accepted.
|
427
|
+
mask : array_like, optional
|
428
|
+
If a mask is given, only those elements with a True value at
|
429
|
+
the corresponding mask element are modified at each iteration.
|
430
|
+
output : ndarray, optional
|
431
|
+
Array of the same shape as input, into which the output is placed.
|
432
|
+
By default, a new array is created.
|
433
|
+
border_value : int (cast to 0 or 1), optional
|
434
|
+
Value at the border in the output array.
|
435
|
+
origin : int or tuple of ints, optional
|
436
|
+
Placement of the filter, by default 0.
|
437
|
+
brute_force : boolean, optional
|
438
|
+
Memory condition: if False, only the pixels whose value was changed in
|
439
|
+
the last iteration are tracked as candidates to be updated (dilated)
|
440
|
+
in the current iteration; if True all pixels are considered as
|
441
|
+
candidates for dilation, regardless of what happened in the previous
|
442
|
+
iteration. False by default.
|
443
|
+
axes : tuple of int or None
|
444
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
445
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
446
|
+
the number of axes.
|
447
|
+
|
448
|
+
Returns
|
449
|
+
-------
|
450
|
+
binary_dilation : ndarray of bools
|
451
|
+
Dilation of the input by the structuring element.
|
452
|
+
|
453
|
+
See Also
|
454
|
+
--------
|
455
|
+
grey_dilation, binary_erosion, binary_closing, binary_opening,
|
456
|
+
generate_binary_structure
|
457
|
+
|
458
|
+
Notes
|
459
|
+
-----
|
460
|
+
Dilation [1]_ is a mathematical morphology operation [2]_ that uses a
|
461
|
+
structuring element for expanding the shapes in an image. The binary
|
462
|
+
dilation of an image by a structuring element is the locus of the points
|
463
|
+
covered by the structuring element, when its center lies within the
|
464
|
+
non-zero points of the image.
|
465
|
+
|
466
|
+
References
|
467
|
+
----------
|
468
|
+
.. [1] https://en.wikipedia.org/wiki/Dilation_%28morphology%29
|
469
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
470
|
+
|
471
|
+
Examples
|
472
|
+
--------
|
473
|
+
>>> from scipy import ndimage
|
474
|
+
>>> import numpy as np
|
475
|
+
>>> a = np.zeros((5, 5))
|
476
|
+
>>> a[2, 2] = 1
|
477
|
+
>>> a
|
478
|
+
array([[ 0., 0., 0., 0., 0.],
|
479
|
+
[ 0., 0., 0., 0., 0.],
|
480
|
+
[ 0., 0., 1., 0., 0.],
|
481
|
+
[ 0., 0., 0., 0., 0.],
|
482
|
+
[ 0., 0., 0., 0., 0.]])
|
483
|
+
>>> ndimage.binary_dilation(a)
|
484
|
+
array([[False, False, False, False, False],
|
485
|
+
[False, False, True, False, False],
|
486
|
+
[False, True, True, True, False],
|
487
|
+
[False, False, True, False, False],
|
488
|
+
[False, False, False, False, False]], dtype=bool)
|
489
|
+
>>> ndimage.binary_dilation(a).astype(a.dtype)
|
490
|
+
array([[ 0., 0., 0., 0., 0.],
|
491
|
+
[ 0., 0., 1., 0., 0.],
|
492
|
+
[ 0., 1., 1., 1., 0.],
|
493
|
+
[ 0., 0., 1., 0., 0.],
|
494
|
+
[ 0., 0., 0., 0., 0.]])
|
495
|
+
>>> # 3x3 structuring element with connectivity 1, used by default
|
496
|
+
>>> struct1 = ndimage.generate_binary_structure(2, 1)
|
497
|
+
>>> struct1
|
498
|
+
array([[False, True, False],
|
499
|
+
[ True, True, True],
|
500
|
+
[False, True, False]], dtype=bool)
|
501
|
+
>>> # 3x3 structuring element with connectivity 2
|
502
|
+
>>> struct2 = ndimage.generate_binary_structure(2, 2)
|
503
|
+
>>> struct2
|
504
|
+
array([[ True, True, True],
|
505
|
+
[ True, True, True],
|
506
|
+
[ True, True, True]], dtype=bool)
|
507
|
+
>>> ndimage.binary_dilation(a, structure=struct1).astype(a.dtype)
|
508
|
+
array([[ 0., 0., 0., 0., 0.],
|
509
|
+
[ 0., 0., 1., 0., 0.],
|
510
|
+
[ 0., 1., 1., 1., 0.],
|
511
|
+
[ 0., 0., 1., 0., 0.],
|
512
|
+
[ 0., 0., 0., 0., 0.]])
|
513
|
+
>>> ndimage.binary_dilation(a, structure=struct2).astype(a.dtype)
|
514
|
+
array([[ 0., 0., 0., 0., 0.],
|
515
|
+
[ 0., 1., 1., 1., 0.],
|
516
|
+
[ 0., 1., 1., 1., 0.],
|
517
|
+
[ 0., 1., 1., 1., 0.],
|
518
|
+
[ 0., 0., 0., 0., 0.]])
|
519
|
+
>>> ndimage.binary_dilation(a, structure=struct1,\\
|
520
|
+
... iterations=2).astype(a.dtype)
|
521
|
+
array([[ 0., 0., 1., 0., 0.],
|
522
|
+
[ 0., 1., 1., 1., 0.],
|
523
|
+
[ 1., 1., 1., 1., 1.],
|
524
|
+
[ 0., 1., 1., 1., 0.],
|
525
|
+
[ 0., 0., 1., 0., 0.]])
|
526
|
+
|
527
|
+
"""
|
528
|
+
input = np.asarray(input)
|
529
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
530
|
+
num_axes = len(axes)
|
531
|
+
if structure is None:
|
532
|
+
structure = generate_binary_structure(num_axes, 1)
|
533
|
+
origin = _ni_support._normalize_sequence(origin, num_axes)
|
534
|
+
structure = np.asarray(structure)
|
535
|
+
structure = structure[tuple([slice(None, None, -1)] *
|
536
|
+
structure.ndim)]
|
537
|
+
for ii in range(len(origin)):
|
538
|
+
origin[ii] = -origin[ii]
|
539
|
+
if not structure.shape[ii] & 1:
|
540
|
+
origin[ii] -= 1
|
541
|
+
|
542
|
+
return _binary_erosion(input, structure, iterations, mask,
|
543
|
+
output, border_value, origin, 1, brute_force, axes)
|
544
|
+
|
545
|
+
|
546
|
+
def binary_opening(input, structure=None, iterations=1, output=None,
|
547
|
+
origin=0, mask=None, border_value=0, brute_force=False, *,
|
548
|
+
axes=None):
|
549
|
+
"""
|
550
|
+
Multidimensional binary opening with the given structuring element.
|
551
|
+
|
552
|
+
The *opening* of an input image by a structuring element is the
|
553
|
+
*dilation* of the *erosion* of the image by the structuring element.
|
554
|
+
|
555
|
+
Parameters
|
556
|
+
----------
|
557
|
+
input : array_like
|
558
|
+
Binary array_like to be opened. Non-zero (True) elements form
|
559
|
+
the subset to be opened.
|
560
|
+
structure : array_like, optional
|
561
|
+
Structuring element used for the opening. Non-zero elements are
|
562
|
+
considered True. If no structuring element is provided an element
|
563
|
+
is generated with a square connectivity equal to one (i.e., only
|
564
|
+
nearest neighbors are connected to the center, diagonally-connected
|
565
|
+
elements are not considered neighbors).
|
566
|
+
iterations : int, optional
|
567
|
+
The erosion step of the opening, then the dilation step are each
|
568
|
+
repeated `iterations` times (one, by default). If `iterations` is
|
569
|
+
less than 1, each operation is repeated until the result does
|
570
|
+
not change anymore. Only an integer of iterations is accepted.
|
571
|
+
output : ndarray, optional
|
572
|
+
Array of the same shape as input, into which the output is placed.
|
573
|
+
By default, a new array is created.
|
574
|
+
origin : int or tuple of ints, optional
|
575
|
+
Placement of the filter, by default 0.
|
576
|
+
mask : array_like, optional
|
577
|
+
If a mask is given, only those elements with a True value at
|
578
|
+
the corresponding mask element are modified at each iteration.
|
579
|
+
|
580
|
+
.. versionadded:: 1.1.0
|
581
|
+
border_value : int (cast to 0 or 1), optional
|
582
|
+
Value at the border in the output array.
|
583
|
+
|
584
|
+
.. versionadded:: 1.1.0
|
585
|
+
brute_force : boolean, optional
|
586
|
+
Memory condition: if False, only the pixels whose value was changed in
|
587
|
+
the last iteration are tracked as candidates to be updated in the
|
588
|
+
current iteration; if true all pixels are considered as candidates for
|
589
|
+
update, regardless of what happened in the previous iteration.
|
590
|
+
False by default.
|
591
|
+
|
592
|
+
.. versionadded:: 1.1.0
|
593
|
+
axes : tuple of int or None
|
594
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
595
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
596
|
+
the number of axes.
|
597
|
+
|
598
|
+
Returns
|
599
|
+
-------
|
600
|
+
binary_opening : ndarray of bools
|
601
|
+
Opening of the input by the structuring element.
|
602
|
+
|
603
|
+
See Also
|
604
|
+
--------
|
605
|
+
grey_opening, binary_closing, binary_erosion, binary_dilation,
|
606
|
+
generate_binary_structure
|
607
|
+
|
608
|
+
Notes
|
609
|
+
-----
|
610
|
+
*Opening* [1]_ is a mathematical morphology operation [2]_ that
|
611
|
+
consists in the succession of an erosion and a dilation of the
|
612
|
+
input with the same structuring element. Opening, therefore, removes
|
613
|
+
objects smaller than the structuring element.
|
614
|
+
|
615
|
+
Together with *closing* (`binary_closing`), opening can be used for
|
616
|
+
noise removal.
|
617
|
+
|
618
|
+
References
|
619
|
+
----------
|
620
|
+
.. [1] https://en.wikipedia.org/wiki/Opening_%28morphology%29
|
621
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
622
|
+
|
623
|
+
Examples
|
624
|
+
--------
|
625
|
+
>>> from scipy import ndimage
|
626
|
+
>>> import numpy as np
|
627
|
+
>>> a = np.zeros((5,5), dtype=int)
|
628
|
+
>>> a[1:4, 1:4] = 1; a[4, 4] = 1
|
629
|
+
>>> a
|
630
|
+
array([[0, 0, 0, 0, 0],
|
631
|
+
[0, 1, 1, 1, 0],
|
632
|
+
[0, 1, 1, 1, 0],
|
633
|
+
[0, 1, 1, 1, 0],
|
634
|
+
[0, 0, 0, 0, 1]])
|
635
|
+
>>> # Opening removes small objects
|
636
|
+
>>> ndimage.binary_opening(a, structure=np.ones((3,3))).astype(int)
|
637
|
+
array([[0, 0, 0, 0, 0],
|
638
|
+
[0, 1, 1, 1, 0],
|
639
|
+
[0, 1, 1, 1, 0],
|
640
|
+
[0, 1, 1, 1, 0],
|
641
|
+
[0, 0, 0, 0, 0]])
|
642
|
+
>>> # Opening can also smooth corners
|
643
|
+
>>> ndimage.binary_opening(a).astype(int)
|
644
|
+
array([[0, 0, 0, 0, 0],
|
645
|
+
[0, 0, 1, 0, 0],
|
646
|
+
[0, 1, 1, 1, 0],
|
647
|
+
[0, 0, 1, 0, 0],
|
648
|
+
[0, 0, 0, 0, 0]])
|
649
|
+
>>> # Opening is the dilation of the erosion of the input
|
650
|
+
>>> ndimage.binary_erosion(a).astype(int)
|
651
|
+
array([[0, 0, 0, 0, 0],
|
652
|
+
[0, 0, 0, 0, 0],
|
653
|
+
[0, 0, 1, 0, 0],
|
654
|
+
[0, 0, 0, 0, 0],
|
655
|
+
[0, 0, 0, 0, 0]])
|
656
|
+
>>> ndimage.binary_dilation(ndimage.binary_erosion(a)).astype(int)
|
657
|
+
array([[0, 0, 0, 0, 0],
|
658
|
+
[0, 0, 1, 0, 0],
|
659
|
+
[0, 1, 1, 1, 0],
|
660
|
+
[0, 0, 1, 0, 0],
|
661
|
+
[0, 0, 0, 0, 0]])
|
662
|
+
|
663
|
+
"""
|
664
|
+
input = np.asarray(input)
|
665
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
666
|
+
num_axes = len(axes)
|
667
|
+
if structure is None:
|
668
|
+
structure = generate_binary_structure(num_axes, 1)
|
669
|
+
|
670
|
+
tmp = binary_erosion(input, structure, iterations, mask, None,
|
671
|
+
border_value, origin, brute_force, axes=axes)
|
672
|
+
return binary_dilation(tmp, structure, iterations, mask, output,
|
673
|
+
border_value, origin, brute_force, axes=axes)
|
674
|
+
|
675
|
+
|
676
|
+
def binary_closing(input, structure=None, iterations=1, output=None,
|
677
|
+
origin=0, mask=None, border_value=0, brute_force=False, *,
|
678
|
+
axes=None):
|
679
|
+
"""
|
680
|
+
Multidimensional binary closing with the given structuring element.
|
681
|
+
|
682
|
+
The *closing* of an input image by a structuring element is the
|
683
|
+
*erosion* of the *dilation* of the image by the structuring element.
|
684
|
+
|
685
|
+
Parameters
|
686
|
+
----------
|
687
|
+
input : array_like
|
688
|
+
Binary array_like to be closed. Non-zero (True) elements form
|
689
|
+
the subset to be closed.
|
690
|
+
structure : array_like, optional
|
691
|
+
Structuring element used for the closing. Non-zero elements are
|
692
|
+
considered True. If no structuring element is provided an element
|
693
|
+
is generated with a square connectivity equal to one (i.e., only
|
694
|
+
nearest neighbors are connected to the center, diagonally-connected
|
695
|
+
elements are not considered neighbors).
|
696
|
+
iterations : int, optional
|
697
|
+
The dilation step of the closing, then the erosion step are each
|
698
|
+
repeated `iterations` times (one, by default). If iterations is
|
699
|
+
less than 1, each operations is repeated until the result does
|
700
|
+
not change anymore. Only an integer of iterations is accepted.
|
701
|
+
output : ndarray, optional
|
702
|
+
Array of the same shape as input, into which the output is placed.
|
703
|
+
By default, a new array is created.
|
704
|
+
origin : int or tuple of ints, optional
|
705
|
+
Placement of the filter, by default 0.
|
706
|
+
mask : array_like, optional
|
707
|
+
If a mask is given, only those elements with a True value at
|
708
|
+
the corresponding mask element are modified at each iteration.
|
709
|
+
|
710
|
+
.. versionadded:: 1.1.0
|
711
|
+
border_value : int (cast to 0 or 1), optional
|
712
|
+
Value at the border in the output array.
|
713
|
+
|
714
|
+
.. versionadded:: 1.1.0
|
715
|
+
brute_force : boolean, optional
|
716
|
+
Memory condition: if False, only the pixels whose value was changed in
|
717
|
+
the last iteration are tracked as candidates to be updated in the
|
718
|
+
current iteration; if true al pixels are considered as candidates for
|
719
|
+
update, regardless of what happened in the previous iteration.
|
720
|
+
False by default.
|
721
|
+
|
722
|
+
.. versionadded:: 1.1.0
|
723
|
+
axes : tuple of int or None
|
724
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
725
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
726
|
+
the number of axes.
|
727
|
+
|
728
|
+
Returns
|
729
|
+
-------
|
730
|
+
binary_closing : ndarray of bools
|
731
|
+
Closing of the input by the structuring element.
|
732
|
+
|
733
|
+
See Also
|
734
|
+
--------
|
735
|
+
grey_closing, binary_opening, binary_dilation, binary_erosion,
|
736
|
+
generate_binary_structure
|
737
|
+
|
738
|
+
Notes
|
739
|
+
-----
|
740
|
+
*Closing* [1]_ is a mathematical morphology operation [2]_ that
|
741
|
+
consists in the succession of a dilation and an erosion of the
|
742
|
+
input with the same structuring element. Closing therefore fills
|
743
|
+
holes smaller than the structuring element.
|
744
|
+
|
745
|
+
Together with *opening* (`binary_opening`), closing can be used for
|
746
|
+
noise removal.
|
747
|
+
|
748
|
+
References
|
749
|
+
----------
|
750
|
+
.. [1] https://en.wikipedia.org/wiki/Closing_%28morphology%29
|
751
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
752
|
+
|
753
|
+
Examples
|
754
|
+
--------
|
755
|
+
>>> from scipy import ndimage
|
756
|
+
>>> import numpy as np
|
757
|
+
>>> a = np.zeros((5,5), dtype=int)
|
758
|
+
>>> a[1:-1, 1:-1] = 1; a[2,2] = 0
|
759
|
+
>>> a
|
760
|
+
array([[0, 0, 0, 0, 0],
|
761
|
+
[0, 1, 1, 1, 0],
|
762
|
+
[0, 1, 0, 1, 0],
|
763
|
+
[0, 1, 1, 1, 0],
|
764
|
+
[0, 0, 0, 0, 0]])
|
765
|
+
>>> # Closing removes small holes
|
766
|
+
>>> ndimage.binary_closing(a).astype(int)
|
767
|
+
array([[0, 0, 0, 0, 0],
|
768
|
+
[0, 1, 1, 1, 0],
|
769
|
+
[0, 1, 1, 1, 0],
|
770
|
+
[0, 1, 1, 1, 0],
|
771
|
+
[0, 0, 0, 0, 0]])
|
772
|
+
>>> # Closing is the erosion of the dilation of the input
|
773
|
+
>>> ndimage.binary_dilation(a).astype(int)
|
774
|
+
array([[0, 1, 1, 1, 0],
|
775
|
+
[1, 1, 1, 1, 1],
|
776
|
+
[1, 1, 1, 1, 1],
|
777
|
+
[1, 1, 1, 1, 1],
|
778
|
+
[0, 1, 1, 1, 0]])
|
779
|
+
>>> ndimage.binary_erosion(ndimage.binary_dilation(a)).astype(int)
|
780
|
+
array([[0, 0, 0, 0, 0],
|
781
|
+
[0, 1, 1, 1, 0],
|
782
|
+
[0, 1, 1, 1, 0],
|
783
|
+
[0, 1, 1, 1, 0],
|
784
|
+
[0, 0, 0, 0, 0]])
|
785
|
+
|
786
|
+
|
787
|
+
>>> a = np.zeros((7,7), dtype=int)
|
788
|
+
>>> a[1:6, 2:5] = 1; a[1:3,3] = 0
|
789
|
+
>>> a
|
790
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
791
|
+
[0, 0, 1, 0, 1, 0, 0],
|
792
|
+
[0, 0, 1, 0, 1, 0, 0],
|
793
|
+
[0, 0, 1, 1, 1, 0, 0],
|
794
|
+
[0, 0, 1, 1, 1, 0, 0],
|
795
|
+
[0, 0, 1, 1, 1, 0, 0],
|
796
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
797
|
+
>>> # In addition to removing holes, closing can also
|
798
|
+
>>> # coarsen boundaries with fine hollows.
|
799
|
+
>>> ndimage.binary_closing(a).astype(int)
|
800
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
801
|
+
[0, 0, 1, 0, 1, 0, 0],
|
802
|
+
[0, 0, 1, 1, 1, 0, 0],
|
803
|
+
[0, 0, 1, 1, 1, 0, 0],
|
804
|
+
[0, 0, 1, 1, 1, 0, 0],
|
805
|
+
[0, 0, 1, 1, 1, 0, 0],
|
806
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
807
|
+
>>> ndimage.binary_closing(a, structure=np.ones((2,2))).astype(int)
|
808
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
809
|
+
[0, 0, 1, 1, 1, 0, 0],
|
810
|
+
[0, 0, 1, 1, 1, 0, 0],
|
811
|
+
[0, 0, 1, 1, 1, 0, 0],
|
812
|
+
[0, 0, 1, 1, 1, 0, 0],
|
813
|
+
[0, 0, 1, 1, 1, 0, 0],
|
814
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
815
|
+
|
816
|
+
"""
|
817
|
+
input = np.asarray(input)
|
818
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
819
|
+
num_axes = len(axes)
|
820
|
+
if structure is None:
|
821
|
+
structure = generate_binary_structure(num_axes, 1)
|
822
|
+
|
823
|
+
tmp = binary_dilation(input, structure, iterations, mask, None,
|
824
|
+
border_value, origin, brute_force, axes=axes)
|
825
|
+
return binary_erosion(tmp, structure, iterations, mask, output,
|
826
|
+
border_value, origin, brute_force, axes=axes)
|
827
|
+
|
828
|
+
|
829
|
+
def binary_hit_or_miss(input, structure1=None, structure2=None,
|
830
|
+
output=None, origin1=0, origin2=None, *, axes=None):
|
831
|
+
"""
|
832
|
+
Multidimensional binary hit-or-miss transform.
|
833
|
+
|
834
|
+
The hit-or-miss transform finds the locations of a given pattern
|
835
|
+
inside the input image.
|
836
|
+
|
837
|
+
Parameters
|
838
|
+
----------
|
839
|
+
input : array_like (cast to booleans)
|
840
|
+
Binary image where a pattern is to be detected.
|
841
|
+
structure1 : array_like (cast to booleans), optional
|
842
|
+
Part of the structuring element to be fitted to the foreground
|
843
|
+
(non-zero elements) of `input`. If no value is provided, a
|
844
|
+
structure of square connectivity 1 is chosen.
|
845
|
+
structure2 : array_like (cast to booleans), optional
|
846
|
+
Second part of the structuring element that has to miss completely
|
847
|
+
the foreground. If no value is provided, the complementary of
|
848
|
+
`structure1` is taken.
|
849
|
+
output : ndarray, optional
|
850
|
+
Array of the same shape as input, into which the output is placed.
|
851
|
+
By default, a new array is created.
|
852
|
+
origin1 : int or tuple of ints, optional
|
853
|
+
Placement of the first part of the structuring element `structure1`,
|
854
|
+
by default 0 for a centered structure.
|
855
|
+
origin2 : int or tuple of ints, optional
|
856
|
+
Placement of the second part of the structuring element `structure2`,
|
857
|
+
by default 0 for a centered structure. If a value is provided for
|
858
|
+
`origin1` and not for `origin2`, then `origin2` is set to `origin1`.
|
859
|
+
axes : tuple of int or None
|
860
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
861
|
+
along all axes. If `origin1` or `origin2` tuples are provided, their
|
862
|
+
length must match the number of axes.
|
863
|
+
|
864
|
+
Returns
|
865
|
+
-------
|
866
|
+
binary_hit_or_miss : ndarray
|
867
|
+
Hit-or-miss transform of `input` with the given structuring
|
868
|
+
element (`structure1`, `structure2`).
|
869
|
+
|
870
|
+
See Also
|
871
|
+
--------
|
872
|
+
binary_erosion
|
873
|
+
|
874
|
+
References
|
875
|
+
----------
|
876
|
+
.. [1] https://en.wikipedia.org/wiki/Hit-or-miss_transform
|
877
|
+
|
878
|
+
Examples
|
879
|
+
--------
|
880
|
+
>>> from scipy import ndimage
|
881
|
+
>>> import numpy as np
|
882
|
+
>>> a = np.zeros((7,7), dtype=int)
|
883
|
+
>>> a[1, 1] = 1; a[2:4, 2:4] = 1; a[4:6, 4:6] = 1
|
884
|
+
>>> a
|
885
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
886
|
+
[0, 1, 0, 0, 0, 0, 0],
|
887
|
+
[0, 0, 1, 1, 0, 0, 0],
|
888
|
+
[0, 0, 1, 1, 0, 0, 0],
|
889
|
+
[0, 0, 0, 0, 1, 1, 0],
|
890
|
+
[0, 0, 0, 0, 1, 1, 0],
|
891
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
892
|
+
>>> structure1 = np.array([[1, 0, 0], [0, 1, 1], [0, 1, 1]])
|
893
|
+
>>> structure1
|
894
|
+
array([[1, 0, 0],
|
895
|
+
[0, 1, 1],
|
896
|
+
[0, 1, 1]])
|
897
|
+
>>> # Find the matches of structure1 in the array a
|
898
|
+
>>> ndimage.binary_hit_or_miss(a, structure1=structure1).astype(int)
|
899
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
900
|
+
[0, 0, 0, 0, 0, 0, 0],
|
901
|
+
[0, 0, 1, 0, 0, 0, 0],
|
902
|
+
[0, 0, 0, 0, 0, 0, 0],
|
903
|
+
[0, 0, 0, 0, 1, 0, 0],
|
904
|
+
[0, 0, 0, 0, 0, 0, 0],
|
905
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
906
|
+
>>> # Change the origin of the filter
|
907
|
+
>>> # origin1=1 is equivalent to origin1=(1,1) here
|
908
|
+
>>> ndimage.binary_hit_or_miss(a, structure1=structure1,\\
|
909
|
+
... origin1=1).astype(int)
|
910
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
911
|
+
[0, 0, 0, 0, 0, 0, 0],
|
912
|
+
[0, 0, 0, 0, 0, 0, 0],
|
913
|
+
[0, 0, 0, 1, 0, 0, 0],
|
914
|
+
[0, 0, 0, 0, 0, 0, 0],
|
915
|
+
[0, 0, 0, 0, 0, 1, 0],
|
916
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
917
|
+
|
918
|
+
"""
|
919
|
+
input = np.asarray(input)
|
920
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
921
|
+
num_axes = len(axes)
|
922
|
+
if structure1 is None:
|
923
|
+
structure1 = generate_binary_structure(num_axes, 1)
|
924
|
+
else:
|
925
|
+
structure1 = np.asarray(structure1)
|
926
|
+
if structure2 is None:
|
927
|
+
structure2 = np.logical_not(structure1)
|
928
|
+
origin1 = _ni_support._normalize_sequence(origin1, num_axes)
|
929
|
+
if origin2 is None:
|
930
|
+
origin2 = origin1
|
931
|
+
else:
|
932
|
+
origin2 = _ni_support._normalize_sequence(origin2, num_axes)
|
933
|
+
|
934
|
+
tmp1 = _binary_erosion(input, structure1, 1, None, None, 0, origin1,
|
935
|
+
0, False, axes)
|
936
|
+
inplace = isinstance(output, np.ndarray)
|
937
|
+
result = _binary_erosion(input, structure2, 1, None, output, 0,
|
938
|
+
origin2, 1, False, axes)
|
939
|
+
if inplace:
|
940
|
+
np.logical_not(output, output)
|
941
|
+
np.logical_and(tmp1, output, output)
|
942
|
+
else:
|
943
|
+
np.logical_not(result, result)
|
944
|
+
return np.logical_and(tmp1, result)
|
945
|
+
|
946
|
+
|
947
|
+
def binary_propagation(input, structure=None, mask=None,
|
948
|
+
output=None, border_value=0, origin=0, *, axes=None):
|
949
|
+
"""
|
950
|
+
Multidimensional binary propagation with the given structuring element.
|
951
|
+
|
952
|
+
Parameters
|
953
|
+
----------
|
954
|
+
input : array_like
|
955
|
+
Binary image to be propagated inside `mask`.
|
956
|
+
structure : array_like, optional
|
957
|
+
Structuring element used in the successive dilations. The output
|
958
|
+
may depend on the structuring element, especially if `mask` has
|
959
|
+
several connex components. If no structuring element is
|
960
|
+
provided, an element is generated with a squared connectivity equal
|
961
|
+
to one.
|
962
|
+
mask : array_like, optional
|
963
|
+
Binary mask defining the region into which `input` is allowed to
|
964
|
+
propagate.
|
965
|
+
output : ndarray, optional
|
966
|
+
Array of the same shape as input, into which the output is placed.
|
967
|
+
By default, a new array is created.
|
968
|
+
border_value : int (cast to 0 or 1), optional
|
969
|
+
Value at the border in the output array.
|
970
|
+
origin : int or tuple of ints, optional
|
971
|
+
Placement of the filter, by default 0.
|
972
|
+
axes : tuple of int or None
|
973
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
974
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
975
|
+
the number of axes.
|
976
|
+
|
977
|
+
Returns
|
978
|
+
-------
|
979
|
+
binary_propagation : ndarray
|
980
|
+
Binary propagation of `input` inside `mask`.
|
981
|
+
|
982
|
+
Notes
|
983
|
+
-----
|
984
|
+
This function is functionally equivalent to calling binary_dilation
|
985
|
+
with the number of iterations less than one: iterative dilation until
|
986
|
+
the result does not change anymore.
|
987
|
+
|
988
|
+
The succession of an erosion and propagation inside the original image
|
989
|
+
can be used instead of an *opening* for deleting small objects while
|
990
|
+
keeping the contours of larger objects untouched.
|
991
|
+
|
992
|
+
References
|
993
|
+
----------
|
994
|
+
.. [1] http://cmm.ensmp.fr/~serra/cours/pdf/en/ch6en.pdf, slide 15.
|
995
|
+
.. [2] I.T. Young, J.J. Gerbrands, and L.J. van Vliet, "Fundamentals of
|
996
|
+
image processing", 1998
|
997
|
+
ftp://qiftp.tudelft.nl/DIPimage/docs/FIP2.3.pdf
|
998
|
+
|
999
|
+
Examples
|
1000
|
+
--------
|
1001
|
+
>>> from scipy import ndimage
|
1002
|
+
>>> import numpy as np
|
1003
|
+
>>> input = np.zeros((8, 8), dtype=int)
|
1004
|
+
>>> input[2, 2] = 1
|
1005
|
+
>>> mask = np.zeros((8, 8), dtype=int)
|
1006
|
+
>>> mask[1:4, 1:4] = mask[4, 4] = mask[6:8, 6:8] = 1
|
1007
|
+
>>> input
|
1008
|
+
array([[0, 0, 0, 0, 0, 0, 0, 0],
|
1009
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1010
|
+
[0, 0, 1, 0, 0, 0, 0, 0],
|
1011
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1012
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1013
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1014
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1015
|
+
[0, 0, 0, 0, 0, 0, 0, 0]])
|
1016
|
+
>>> mask
|
1017
|
+
array([[0, 0, 0, 0, 0, 0, 0, 0],
|
1018
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1019
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1020
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1021
|
+
[0, 0, 0, 0, 1, 0, 0, 0],
|
1022
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1023
|
+
[0, 0, 0, 0, 0, 0, 1, 1],
|
1024
|
+
[0, 0, 0, 0, 0, 0, 1, 1]])
|
1025
|
+
>>> ndimage.binary_propagation(input, mask=mask).astype(int)
|
1026
|
+
array([[0, 0, 0, 0, 0, 0, 0, 0],
|
1027
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1028
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1029
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1030
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1031
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1032
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1033
|
+
[0, 0, 0, 0, 0, 0, 0, 0]])
|
1034
|
+
>>> ndimage.binary_propagation(input, mask=mask,\\
|
1035
|
+
... structure=np.ones((3,3))).astype(int)
|
1036
|
+
array([[0, 0, 0, 0, 0, 0, 0, 0],
|
1037
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1038
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1039
|
+
[0, 1, 1, 1, 0, 0, 0, 0],
|
1040
|
+
[0, 0, 0, 0, 1, 0, 0, 0],
|
1041
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1042
|
+
[0, 0, 0, 0, 0, 0, 0, 0],
|
1043
|
+
[0, 0, 0, 0, 0, 0, 0, 0]])
|
1044
|
+
|
1045
|
+
>>> # Comparison between opening and erosion+propagation
|
1046
|
+
>>> a = np.zeros((6,6), dtype=int)
|
1047
|
+
>>> a[2:5, 2:5] = 1; a[0, 0] = 1; a[5, 5] = 1
|
1048
|
+
>>> a
|
1049
|
+
array([[1, 0, 0, 0, 0, 0],
|
1050
|
+
[0, 0, 0, 0, 0, 0],
|
1051
|
+
[0, 0, 1, 1, 1, 0],
|
1052
|
+
[0, 0, 1, 1, 1, 0],
|
1053
|
+
[0, 0, 1, 1, 1, 0],
|
1054
|
+
[0, 0, 0, 0, 0, 1]])
|
1055
|
+
>>> ndimage.binary_opening(a).astype(int)
|
1056
|
+
array([[0, 0, 0, 0, 0, 0],
|
1057
|
+
[0, 0, 0, 0, 0, 0],
|
1058
|
+
[0, 0, 0, 1, 0, 0],
|
1059
|
+
[0, 0, 1, 1, 1, 0],
|
1060
|
+
[0, 0, 0, 1, 0, 0],
|
1061
|
+
[0, 0, 0, 0, 0, 0]])
|
1062
|
+
>>> b = ndimage.binary_erosion(a)
|
1063
|
+
>>> b.astype(int)
|
1064
|
+
array([[0, 0, 0, 0, 0, 0],
|
1065
|
+
[0, 0, 0, 0, 0, 0],
|
1066
|
+
[0, 0, 0, 0, 0, 0],
|
1067
|
+
[0, 0, 0, 1, 0, 0],
|
1068
|
+
[0, 0, 0, 0, 0, 0],
|
1069
|
+
[0, 0, 0, 0, 0, 0]])
|
1070
|
+
>>> ndimage.binary_propagation(b, mask=a).astype(int)
|
1071
|
+
array([[0, 0, 0, 0, 0, 0],
|
1072
|
+
[0, 0, 0, 0, 0, 0],
|
1073
|
+
[0, 0, 1, 1, 1, 0],
|
1074
|
+
[0, 0, 1, 1, 1, 0],
|
1075
|
+
[0, 0, 1, 1, 1, 0],
|
1076
|
+
[0, 0, 0, 0, 0, 0]])
|
1077
|
+
|
1078
|
+
"""
|
1079
|
+
return binary_dilation(input, structure, -1, mask, output,
|
1080
|
+
border_value, origin, axes=axes)
|
1081
|
+
|
1082
|
+
|
1083
|
+
def binary_fill_holes(input, structure=None, output=None, origin=0, *,
|
1084
|
+
axes=None):
|
1085
|
+
"""
|
1086
|
+
Fill the holes in binary objects.
|
1087
|
+
|
1088
|
+
|
1089
|
+
Parameters
|
1090
|
+
----------
|
1091
|
+
input : array_like
|
1092
|
+
N-D binary array with holes to be filled
|
1093
|
+
structure : array_like, optional
|
1094
|
+
Structuring element used in the computation; large-size elements
|
1095
|
+
make computations faster but may miss holes separated from the
|
1096
|
+
background by thin regions. The default element (with a square
|
1097
|
+
connectivity equal to one) yields the intuitive result where all
|
1098
|
+
holes in the input have been filled.
|
1099
|
+
output : ndarray, optional
|
1100
|
+
Array of the same shape as input, into which the output is placed.
|
1101
|
+
By default, a new array is created.
|
1102
|
+
origin : int, tuple of ints, optional
|
1103
|
+
Position of the structuring element.
|
1104
|
+
axes : tuple of int or None
|
1105
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1106
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1107
|
+
the number of axes.
|
1108
|
+
|
1109
|
+
Returns
|
1110
|
+
-------
|
1111
|
+
out : ndarray
|
1112
|
+
Transformation of the initial image `input` where holes have been
|
1113
|
+
filled.
|
1114
|
+
|
1115
|
+
See Also
|
1116
|
+
--------
|
1117
|
+
binary_dilation, binary_propagation, label
|
1118
|
+
|
1119
|
+
Notes
|
1120
|
+
-----
|
1121
|
+
The algorithm used in this function consists in invading the complementary
|
1122
|
+
of the shapes in `input` from the outer boundary of the image,
|
1123
|
+
using binary dilations. Holes are not connected to the boundary and are
|
1124
|
+
therefore not invaded. The result is the complementary subset of the
|
1125
|
+
invaded region.
|
1126
|
+
|
1127
|
+
References
|
1128
|
+
----------
|
1129
|
+
.. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1130
|
+
|
1131
|
+
|
1132
|
+
Examples
|
1133
|
+
--------
|
1134
|
+
>>> from scipy import ndimage
|
1135
|
+
>>> import numpy as np
|
1136
|
+
>>> a = np.zeros((5, 5), dtype=int)
|
1137
|
+
>>> a[1:4, 1:4] = 1
|
1138
|
+
>>> a[2,2] = 0
|
1139
|
+
>>> a
|
1140
|
+
array([[0, 0, 0, 0, 0],
|
1141
|
+
[0, 1, 1, 1, 0],
|
1142
|
+
[0, 1, 0, 1, 0],
|
1143
|
+
[0, 1, 1, 1, 0],
|
1144
|
+
[0, 0, 0, 0, 0]])
|
1145
|
+
>>> ndimage.binary_fill_holes(a).astype(int)
|
1146
|
+
array([[0, 0, 0, 0, 0],
|
1147
|
+
[0, 1, 1, 1, 0],
|
1148
|
+
[0, 1, 1, 1, 0],
|
1149
|
+
[0, 1, 1, 1, 0],
|
1150
|
+
[0, 0, 0, 0, 0]])
|
1151
|
+
>>> # Too big structuring element
|
1152
|
+
>>> ndimage.binary_fill_holes(a, structure=np.ones((5,5))).astype(int)
|
1153
|
+
array([[0, 0, 0, 0, 0],
|
1154
|
+
[0, 1, 1, 1, 0],
|
1155
|
+
[0, 1, 0, 1, 0],
|
1156
|
+
[0, 1, 1, 1, 0],
|
1157
|
+
[0, 0, 0, 0, 0]])
|
1158
|
+
|
1159
|
+
"""
|
1160
|
+
input = np.asarray(input)
|
1161
|
+
mask = np.logical_not(input)
|
1162
|
+
tmp = np.zeros(mask.shape, bool)
|
1163
|
+
inplace = isinstance(output, np.ndarray)
|
1164
|
+
if inplace:
|
1165
|
+
binary_dilation(tmp, structure, -1, mask, output, 1, origin, axes=axes)
|
1166
|
+
np.logical_not(output, output)
|
1167
|
+
else:
|
1168
|
+
output = binary_dilation(tmp, structure, -1, mask, None, 1,
|
1169
|
+
origin, axes=axes)
|
1170
|
+
np.logical_not(output, output)
|
1171
|
+
return output
|
1172
|
+
|
1173
|
+
|
1174
|
+
def grey_erosion(input, size=None, footprint=None, structure=None,
|
1175
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1176
|
+
axes=None):
|
1177
|
+
"""
|
1178
|
+
Calculate a greyscale erosion, using either a structuring element,
|
1179
|
+
or a footprint corresponding to a flat structuring element.
|
1180
|
+
|
1181
|
+
Grayscale erosion is a mathematical morphology operation. For the
|
1182
|
+
simple case of a full and flat structuring element, it can be viewed
|
1183
|
+
as a minimum filter over a sliding window.
|
1184
|
+
|
1185
|
+
Parameters
|
1186
|
+
----------
|
1187
|
+
input : array_like
|
1188
|
+
Array over which the grayscale erosion is to be computed.
|
1189
|
+
size : tuple of ints
|
1190
|
+
Shape of a flat and full structuring element used for the grayscale
|
1191
|
+
erosion. Optional if `footprint` or `structure` is provided.
|
1192
|
+
footprint : array of ints, optional
|
1193
|
+
Positions of non-infinite elements of a flat structuring element
|
1194
|
+
used for the grayscale erosion. Non-zero values give the set of
|
1195
|
+
neighbors of the center over which the minimum is chosen.
|
1196
|
+
structure : array of ints, optional
|
1197
|
+
Structuring element used for the grayscale erosion. `structure`
|
1198
|
+
may be a non-flat structuring element. The `structure` array applies a
|
1199
|
+
subtractive offset for each pixel in the neighborhood.
|
1200
|
+
output : array, optional
|
1201
|
+
An array used for storing the output of the erosion may be provided.
|
1202
|
+
mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
|
1203
|
+
The `mode` parameter determines how the array borders are
|
1204
|
+
handled, where `cval` is the value when mode is equal to
|
1205
|
+
'constant'. Default is 'reflect'
|
1206
|
+
cval : scalar, optional
|
1207
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1208
|
+
is 0.0.
|
1209
|
+
origin : scalar, optional
|
1210
|
+
The `origin` parameter controls the placement of the filter.
|
1211
|
+
Default 0
|
1212
|
+
axes : tuple of int or None
|
1213
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1214
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1215
|
+
the number of axes.
|
1216
|
+
|
1217
|
+
Returns
|
1218
|
+
-------
|
1219
|
+
output : ndarray
|
1220
|
+
Grayscale erosion of `input`.
|
1221
|
+
|
1222
|
+
See Also
|
1223
|
+
--------
|
1224
|
+
binary_erosion, grey_dilation, grey_opening, grey_closing
|
1225
|
+
generate_binary_structure, minimum_filter
|
1226
|
+
|
1227
|
+
Notes
|
1228
|
+
-----
|
1229
|
+
The grayscale erosion of an image input by a structuring element s defined
|
1230
|
+
over a domain E is given by:
|
1231
|
+
|
1232
|
+
(input+s)(x) = min {input(y) - s(x-y), for y in E}
|
1233
|
+
|
1234
|
+
In particular, for structuring elements defined as
|
1235
|
+
s(y) = 0 for y in E, the grayscale erosion computes the minimum of the
|
1236
|
+
input image inside a sliding window defined by E.
|
1237
|
+
|
1238
|
+
Grayscale erosion [1]_ is a *mathematical morphology* operation [2]_.
|
1239
|
+
|
1240
|
+
References
|
1241
|
+
----------
|
1242
|
+
.. [1] https://en.wikipedia.org/wiki/Erosion_%28morphology%29
|
1243
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1244
|
+
|
1245
|
+
Examples
|
1246
|
+
--------
|
1247
|
+
>>> from scipy import ndimage
|
1248
|
+
>>> import numpy as np
|
1249
|
+
>>> a = np.zeros((7,7), dtype=int)
|
1250
|
+
>>> a[1:6, 1:6] = 3
|
1251
|
+
>>> a[4,4] = 2; a[2,3] = 1
|
1252
|
+
>>> a
|
1253
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1254
|
+
[0, 3, 3, 3, 3, 3, 0],
|
1255
|
+
[0, 3, 3, 1, 3, 3, 0],
|
1256
|
+
[0, 3, 3, 3, 3, 3, 0],
|
1257
|
+
[0, 3, 3, 3, 2, 3, 0],
|
1258
|
+
[0, 3, 3, 3, 3, 3, 0],
|
1259
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1260
|
+
>>> ndimage.grey_erosion(a, size=(3,3))
|
1261
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1262
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1263
|
+
[0, 0, 1, 1, 1, 0, 0],
|
1264
|
+
[0, 0, 1, 1, 1, 0, 0],
|
1265
|
+
[0, 0, 3, 2, 2, 0, 0],
|
1266
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1267
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1268
|
+
>>> footprint = ndimage.generate_binary_structure(2, 1)
|
1269
|
+
>>> footprint
|
1270
|
+
array([[False, True, False],
|
1271
|
+
[ True, True, True],
|
1272
|
+
[False, True, False]], dtype=bool)
|
1273
|
+
>>> # Diagonally-connected elements are not considered neighbors
|
1274
|
+
>>> ndimage.grey_erosion(a, footprint=footprint)
|
1275
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1276
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1277
|
+
[0, 0, 1, 1, 1, 0, 0],
|
1278
|
+
[0, 0, 3, 1, 2, 0, 0],
|
1279
|
+
[0, 0, 3, 2, 2, 0, 0],
|
1280
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1281
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1282
|
+
|
1283
|
+
"""
|
1284
|
+
if size is None and footprint is None and structure is None:
|
1285
|
+
raise ValueError("size, footprint, or structure must be specified")
|
1286
|
+
|
1287
|
+
return _filters._min_or_max_filter(input, size, footprint, structure,
|
1288
|
+
output, mode, cval, origin, 1,
|
1289
|
+
axes=axes)
|
1290
|
+
|
1291
|
+
|
1292
|
+
def grey_dilation(input, size=None, footprint=None, structure=None,
|
1293
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1294
|
+
axes=None):
|
1295
|
+
"""
|
1296
|
+
Calculate a greyscale dilation, using either a structuring element,
|
1297
|
+
or a footprint corresponding to a flat structuring element.
|
1298
|
+
|
1299
|
+
Grayscale dilation is a mathematical morphology operation. For the
|
1300
|
+
simple case of a full and flat structuring element, it can be viewed
|
1301
|
+
as a maximum filter over a sliding window.
|
1302
|
+
|
1303
|
+
Parameters
|
1304
|
+
----------
|
1305
|
+
input : array_like
|
1306
|
+
Array over which the grayscale dilation is to be computed.
|
1307
|
+
size : tuple of ints
|
1308
|
+
Shape of a flat and full structuring element used for the grayscale
|
1309
|
+
dilation. Optional if `footprint` or `structure` is provided.
|
1310
|
+
footprint : array of ints, optional
|
1311
|
+
Positions of non-infinite elements of a flat structuring element
|
1312
|
+
used for the grayscale dilation. Non-zero values give the set of
|
1313
|
+
neighbors of the center over which the maximum is chosen.
|
1314
|
+
structure : array of ints, optional
|
1315
|
+
Structuring element used for the grayscale dilation. `structure`
|
1316
|
+
may be a non-flat structuring element. The `structure` array applies an
|
1317
|
+
additive offset for each pixel in the neighborhood.
|
1318
|
+
output : array, optional
|
1319
|
+
An array used for storing the output of the dilation may be provided.
|
1320
|
+
mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
|
1321
|
+
The `mode` parameter determines how the array borders are
|
1322
|
+
handled, where `cval` is the value when mode is equal to
|
1323
|
+
'constant'. Default is 'reflect'
|
1324
|
+
cval : scalar, optional
|
1325
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1326
|
+
is 0.0.
|
1327
|
+
origin : scalar, optional
|
1328
|
+
The `origin` parameter controls the placement of the filter.
|
1329
|
+
Default 0
|
1330
|
+
axes : tuple of int or None
|
1331
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1332
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1333
|
+
the number of axes.
|
1334
|
+
|
1335
|
+
Returns
|
1336
|
+
-------
|
1337
|
+
grey_dilation : ndarray
|
1338
|
+
Grayscale dilation of `input`.
|
1339
|
+
|
1340
|
+
See Also
|
1341
|
+
--------
|
1342
|
+
binary_dilation, grey_erosion, grey_closing, grey_opening
|
1343
|
+
generate_binary_structure, maximum_filter
|
1344
|
+
|
1345
|
+
Notes
|
1346
|
+
-----
|
1347
|
+
The grayscale dilation of an image input by a structuring element s defined
|
1348
|
+
over a domain E is given by:
|
1349
|
+
|
1350
|
+
(input+s)(x) = max {input(y) + s(x-y), for y in E}
|
1351
|
+
|
1352
|
+
In particular, for structuring elements defined as
|
1353
|
+
s(y) = 0 for y in E, the grayscale dilation computes the maximum of the
|
1354
|
+
input image inside a sliding window defined by E.
|
1355
|
+
|
1356
|
+
Grayscale dilation [1]_ is a *mathematical morphology* operation [2]_.
|
1357
|
+
|
1358
|
+
References
|
1359
|
+
----------
|
1360
|
+
.. [1] https://en.wikipedia.org/wiki/Dilation_%28morphology%29
|
1361
|
+
.. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1362
|
+
|
1363
|
+
Examples
|
1364
|
+
--------
|
1365
|
+
>>> from scipy import ndimage
|
1366
|
+
>>> import numpy as np
|
1367
|
+
>>> a = np.zeros((7,7), dtype=int)
|
1368
|
+
>>> a[2:5, 2:5] = 1
|
1369
|
+
>>> a[4,4] = 2; a[2,3] = 3
|
1370
|
+
>>> a
|
1371
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1372
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1373
|
+
[0, 0, 1, 3, 1, 0, 0],
|
1374
|
+
[0, 0, 1, 1, 1, 0, 0],
|
1375
|
+
[0, 0, 1, 1, 2, 0, 0],
|
1376
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1377
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1378
|
+
>>> ndimage.grey_dilation(a, size=(3,3))
|
1379
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1380
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1381
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1382
|
+
[0, 1, 3, 3, 3, 2, 0],
|
1383
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1384
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1385
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1386
|
+
>>> ndimage.grey_dilation(a, footprint=np.ones((3,3)))
|
1387
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1388
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1389
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1390
|
+
[0, 1, 3, 3, 3, 2, 0],
|
1391
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1392
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1393
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1394
|
+
>>> s = ndimage.generate_binary_structure(2,1)
|
1395
|
+
>>> s
|
1396
|
+
array([[False, True, False],
|
1397
|
+
[ True, True, True],
|
1398
|
+
[False, True, False]], dtype=bool)
|
1399
|
+
>>> ndimage.grey_dilation(a, footprint=s)
|
1400
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1401
|
+
[0, 0, 1, 3, 1, 0, 0],
|
1402
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1403
|
+
[0, 1, 1, 3, 2, 1, 0],
|
1404
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1405
|
+
[0, 0, 1, 1, 2, 0, 0],
|
1406
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1407
|
+
>>> ndimage.grey_dilation(a, size=(3,3), structure=np.ones((3,3)))
|
1408
|
+
array([[1, 1, 1, 1, 1, 1, 1],
|
1409
|
+
[1, 2, 4, 4, 4, 2, 1],
|
1410
|
+
[1, 2, 4, 4, 4, 2, 1],
|
1411
|
+
[1, 2, 4, 4, 4, 3, 1],
|
1412
|
+
[1, 2, 2, 3, 3, 3, 1],
|
1413
|
+
[1, 2, 2, 3, 3, 3, 1],
|
1414
|
+
[1, 1, 1, 1, 1, 1, 1]])
|
1415
|
+
|
1416
|
+
"""
|
1417
|
+
if size is None and footprint is None and structure is None:
|
1418
|
+
raise ValueError("size, footprint, or structure must be specified")
|
1419
|
+
if structure is not None:
|
1420
|
+
structure = np.asarray(structure)
|
1421
|
+
structure = structure[tuple([slice(None, None, -1)] *
|
1422
|
+
structure.ndim)]
|
1423
|
+
if footprint is not None:
|
1424
|
+
footprint = np.asarray(footprint)
|
1425
|
+
footprint = footprint[tuple([slice(None, None, -1)] *
|
1426
|
+
footprint.ndim)]
|
1427
|
+
|
1428
|
+
input = np.asarray(input)
|
1429
|
+
axes = _ni_support._check_axes(axes, input.ndim)
|
1430
|
+
origin = _ni_support._normalize_sequence(origin, len(axes))
|
1431
|
+
for ii in range(len(origin)):
|
1432
|
+
origin[ii] = -origin[ii]
|
1433
|
+
if footprint is not None:
|
1434
|
+
sz = footprint.shape[ii]
|
1435
|
+
elif structure is not None:
|
1436
|
+
sz = structure.shape[ii]
|
1437
|
+
elif np.isscalar(size):
|
1438
|
+
sz = size
|
1439
|
+
else:
|
1440
|
+
sz = size[ii]
|
1441
|
+
if not sz & 1:
|
1442
|
+
origin[ii] -= 1
|
1443
|
+
|
1444
|
+
return _filters._min_or_max_filter(input, size, footprint, structure,
|
1445
|
+
output, mode, cval, origin, 0,
|
1446
|
+
axes=axes)
|
1447
|
+
|
1448
|
+
|
1449
|
+
def grey_opening(input, size=None, footprint=None, structure=None,
|
1450
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1451
|
+
axes=None):
|
1452
|
+
"""
|
1453
|
+
Multidimensional grayscale opening.
|
1454
|
+
|
1455
|
+
A grayscale opening consists in the succession of a grayscale erosion,
|
1456
|
+
and a grayscale dilation.
|
1457
|
+
|
1458
|
+
Parameters
|
1459
|
+
----------
|
1460
|
+
input : array_like
|
1461
|
+
Array over which the grayscale opening is to be computed.
|
1462
|
+
size : tuple of ints
|
1463
|
+
Shape of a flat and full structuring element used for the grayscale
|
1464
|
+
opening. Optional if `footprint` or `structure` is provided.
|
1465
|
+
footprint : array of ints, optional
|
1466
|
+
Positions of non-infinite elements of a flat structuring element
|
1467
|
+
used for the grayscale opening.
|
1468
|
+
structure : array of ints, optional
|
1469
|
+
Structuring element used for the grayscale opening. `structure`
|
1470
|
+
may be a non-flat structuring element. The `structure` array applies
|
1471
|
+
offsets to the pixels in a neighborhood (the offset is additive during
|
1472
|
+
dilation and subtractive during erosion).
|
1473
|
+
output : array, optional
|
1474
|
+
An array used for storing the output of the opening may be provided.
|
1475
|
+
mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
|
1476
|
+
The `mode` parameter determines how the array borders are
|
1477
|
+
handled, where `cval` is the value when mode is equal to
|
1478
|
+
'constant'. Default is 'reflect'
|
1479
|
+
cval : scalar, optional
|
1480
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1481
|
+
is 0.0.
|
1482
|
+
origin : scalar, optional
|
1483
|
+
The `origin` parameter controls the placement of the filter.
|
1484
|
+
Default 0
|
1485
|
+
axes : tuple of int or None
|
1486
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1487
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1488
|
+
the number of axes.
|
1489
|
+
|
1490
|
+
Returns
|
1491
|
+
-------
|
1492
|
+
grey_opening : ndarray
|
1493
|
+
Result of the grayscale opening of `input` with `structure`.
|
1494
|
+
|
1495
|
+
See Also
|
1496
|
+
--------
|
1497
|
+
binary_opening, grey_dilation, grey_erosion, grey_closing
|
1498
|
+
generate_binary_structure
|
1499
|
+
|
1500
|
+
Notes
|
1501
|
+
-----
|
1502
|
+
The action of a grayscale opening with a flat structuring element amounts
|
1503
|
+
to smoothen high local maxima, whereas binary opening erases small objects.
|
1504
|
+
|
1505
|
+
References
|
1506
|
+
----------
|
1507
|
+
.. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1508
|
+
|
1509
|
+
Examples
|
1510
|
+
--------
|
1511
|
+
>>> from scipy import ndimage
|
1512
|
+
>>> import numpy as np
|
1513
|
+
>>> a = np.arange(36).reshape((6,6))
|
1514
|
+
>>> a[3, 3] = 50
|
1515
|
+
>>> a
|
1516
|
+
array([[ 0, 1, 2, 3, 4, 5],
|
1517
|
+
[ 6, 7, 8, 9, 10, 11],
|
1518
|
+
[12, 13, 14, 15, 16, 17],
|
1519
|
+
[18, 19, 20, 50, 22, 23],
|
1520
|
+
[24, 25, 26, 27, 28, 29],
|
1521
|
+
[30, 31, 32, 33, 34, 35]])
|
1522
|
+
>>> ndimage.grey_opening(a, size=(3,3))
|
1523
|
+
array([[ 0, 1, 2, 3, 4, 4],
|
1524
|
+
[ 6, 7, 8, 9, 10, 10],
|
1525
|
+
[12, 13, 14, 15, 16, 16],
|
1526
|
+
[18, 19, 20, 22, 22, 22],
|
1527
|
+
[24, 25, 26, 27, 28, 28],
|
1528
|
+
[24, 25, 26, 27, 28, 28]])
|
1529
|
+
>>> # Note that the local maximum a[3,3] has disappeared
|
1530
|
+
|
1531
|
+
"""
|
1532
|
+
if (size is not None) and (footprint is not None):
|
1533
|
+
warnings.warn("ignoring size because footprint is set",
|
1534
|
+
UserWarning, stacklevel=2)
|
1535
|
+
tmp = grey_erosion(input, size, footprint, structure, None, mode,
|
1536
|
+
cval, origin, axes=axes)
|
1537
|
+
return grey_dilation(tmp, size, footprint, structure, output, mode,
|
1538
|
+
cval, origin, axes=axes)
|
1539
|
+
|
1540
|
+
|
1541
|
+
def grey_closing(input, size=None, footprint=None, structure=None,
|
1542
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1543
|
+
axes=None):
|
1544
|
+
"""
|
1545
|
+
Multidimensional grayscale closing.
|
1546
|
+
|
1547
|
+
A grayscale closing consists in the succession of a grayscale dilation,
|
1548
|
+
and a grayscale erosion.
|
1549
|
+
|
1550
|
+
Parameters
|
1551
|
+
----------
|
1552
|
+
input : array_like
|
1553
|
+
Array over which the grayscale closing is to be computed.
|
1554
|
+
size : tuple of ints
|
1555
|
+
Shape of a flat and full structuring element used for the grayscale
|
1556
|
+
closing. Optional if `footprint` or `structure` is provided.
|
1557
|
+
footprint : array of ints, optional
|
1558
|
+
Positions of non-infinite elements of a flat structuring element
|
1559
|
+
used for the grayscale closing.
|
1560
|
+
structure : array of ints, optional
|
1561
|
+
Structuring element used for the grayscale closing. `structure`
|
1562
|
+
may be a non-flat structuring element. The `structure` array applies
|
1563
|
+
offsets to the pixels in a neighborhood (the offset is additive during
|
1564
|
+
dilation and subtractive during erosion)
|
1565
|
+
output : array, optional
|
1566
|
+
An array used for storing the output of the closing may be provided.
|
1567
|
+
mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
|
1568
|
+
The `mode` parameter determines how the array borders are
|
1569
|
+
handled, where `cval` is the value when mode is equal to
|
1570
|
+
'constant'. Default is 'reflect'
|
1571
|
+
cval : scalar, optional
|
1572
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1573
|
+
is 0.0.
|
1574
|
+
origin : scalar, optional
|
1575
|
+
The `origin` parameter controls the placement of the filter.
|
1576
|
+
Default 0
|
1577
|
+
axes : tuple of int or None
|
1578
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1579
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1580
|
+
the number of axes.
|
1581
|
+
|
1582
|
+
Returns
|
1583
|
+
-------
|
1584
|
+
grey_closing : ndarray
|
1585
|
+
Result of the grayscale closing of `input` with `structure`.
|
1586
|
+
|
1587
|
+
See Also
|
1588
|
+
--------
|
1589
|
+
binary_closing, grey_dilation, grey_erosion, grey_opening,
|
1590
|
+
generate_binary_structure
|
1591
|
+
|
1592
|
+
Notes
|
1593
|
+
-----
|
1594
|
+
The action of a grayscale closing with a flat structuring element amounts
|
1595
|
+
to smoothen deep local minima, whereas binary closing fills small holes.
|
1596
|
+
|
1597
|
+
References
|
1598
|
+
----------
|
1599
|
+
.. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1600
|
+
|
1601
|
+
Examples
|
1602
|
+
--------
|
1603
|
+
>>> from scipy import ndimage
|
1604
|
+
>>> import numpy as np
|
1605
|
+
>>> a = np.arange(36).reshape((6,6))
|
1606
|
+
>>> a[3,3] = 0
|
1607
|
+
>>> a
|
1608
|
+
array([[ 0, 1, 2, 3, 4, 5],
|
1609
|
+
[ 6, 7, 8, 9, 10, 11],
|
1610
|
+
[12, 13, 14, 15, 16, 17],
|
1611
|
+
[18, 19, 20, 0, 22, 23],
|
1612
|
+
[24, 25, 26, 27, 28, 29],
|
1613
|
+
[30, 31, 32, 33, 34, 35]])
|
1614
|
+
>>> ndimage.grey_closing(a, size=(3,3))
|
1615
|
+
array([[ 7, 7, 8, 9, 10, 11],
|
1616
|
+
[ 7, 7, 8, 9, 10, 11],
|
1617
|
+
[13, 13, 14, 15, 16, 17],
|
1618
|
+
[19, 19, 20, 20, 22, 23],
|
1619
|
+
[25, 25, 26, 27, 28, 29],
|
1620
|
+
[31, 31, 32, 33, 34, 35]])
|
1621
|
+
>>> # Note that the local minimum a[3,3] has disappeared
|
1622
|
+
|
1623
|
+
"""
|
1624
|
+
if (size is not None) and (footprint is not None):
|
1625
|
+
warnings.warn("ignoring size because footprint is set",
|
1626
|
+
UserWarning, stacklevel=2)
|
1627
|
+
tmp = grey_dilation(input, size, footprint, structure, None, mode,
|
1628
|
+
cval, origin, axes=axes)
|
1629
|
+
return grey_erosion(tmp, size, footprint, structure, output, mode,
|
1630
|
+
cval, origin, axes=axes)
|
1631
|
+
|
1632
|
+
|
1633
|
+
def morphological_gradient(input, size=None, footprint=None, structure=None,
|
1634
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1635
|
+
axes=None):
|
1636
|
+
"""
|
1637
|
+
Multidimensional morphological gradient.
|
1638
|
+
|
1639
|
+
The morphological gradient is calculated as the difference between a
|
1640
|
+
dilation and an erosion of the input with a given structuring element.
|
1641
|
+
|
1642
|
+
Parameters
|
1643
|
+
----------
|
1644
|
+
input : array_like
|
1645
|
+
Array over which to compute the morphlogical gradient.
|
1646
|
+
size : tuple of ints
|
1647
|
+
Shape of a flat and full structuring element used for the mathematical
|
1648
|
+
morphology operations. Optional if `footprint` or `structure` is
|
1649
|
+
provided. A larger `size` yields a more blurred gradient.
|
1650
|
+
footprint : array of ints, optional
|
1651
|
+
Positions of non-infinite elements of a flat structuring element
|
1652
|
+
used for the morphology operations. Larger footprints
|
1653
|
+
give a more blurred morphological gradient.
|
1654
|
+
structure : array of ints, optional
|
1655
|
+
Structuring element used for the morphology operations. `structure` may
|
1656
|
+
be a non-flat structuring element. The `structure` array applies
|
1657
|
+
offsets to the pixels in a neighborhood (the offset is additive during
|
1658
|
+
dilation and subtractive during erosion)
|
1659
|
+
output : array, optional
|
1660
|
+
An array used for storing the output of the morphological gradient
|
1661
|
+
may be provided.
|
1662
|
+
mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
|
1663
|
+
The `mode` parameter determines how the array borders are
|
1664
|
+
handled, where `cval` is the value when mode is equal to
|
1665
|
+
'constant'. Default is 'reflect'
|
1666
|
+
cval : scalar, optional
|
1667
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1668
|
+
is 0.0.
|
1669
|
+
origin : scalar, optional
|
1670
|
+
The `origin` parameter controls the placement of the filter.
|
1671
|
+
Default 0
|
1672
|
+
axes : tuple of int or None
|
1673
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1674
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1675
|
+
the number of axes.
|
1676
|
+
|
1677
|
+
Returns
|
1678
|
+
-------
|
1679
|
+
morphological_gradient : ndarray
|
1680
|
+
Morphological gradient of `input`.
|
1681
|
+
|
1682
|
+
See Also
|
1683
|
+
--------
|
1684
|
+
grey_dilation, grey_erosion, gaussian_gradient_magnitude
|
1685
|
+
|
1686
|
+
Notes
|
1687
|
+
-----
|
1688
|
+
For a flat structuring element, the morphological gradient
|
1689
|
+
computed at a given point corresponds to the maximal difference
|
1690
|
+
between elements of the input among the elements covered by the
|
1691
|
+
structuring element centered on the point.
|
1692
|
+
|
1693
|
+
References
|
1694
|
+
----------
|
1695
|
+
.. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
|
1696
|
+
|
1697
|
+
Examples
|
1698
|
+
--------
|
1699
|
+
>>> from scipy import ndimage
|
1700
|
+
>>> import numpy as np
|
1701
|
+
>>> a = np.zeros((7,7), dtype=int)
|
1702
|
+
>>> a[2:5, 2:5] = 1
|
1703
|
+
>>> ndimage.morphological_gradient(a, size=(3,3))
|
1704
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1705
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1706
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1707
|
+
[0, 1, 1, 0, 1, 1, 0],
|
1708
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1709
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1710
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1711
|
+
>>> # The morphological gradient is computed as the difference
|
1712
|
+
>>> # between a dilation and an erosion
|
1713
|
+
>>> ndimage.grey_dilation(a, size=(3,3)) -\\
|
1714
|
+
... ndimage.grey_erosion(a, size=(3,3))
|
1715
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1716
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1717
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1718
|
+
[0, 1, 1, 0, 1, 1, 0],
|
1719
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1720
|
+
[0, 1, 1, 1, 1, 1, 0],
|
1721
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1722
|
+
>>> a = np.zeros((7,7), dtype=int)
|
1723
|
+
>>> a[2:5, 2:5] = 1
|
1724
|
+
>>> a[4,4] = 2; a[2,3] = 3
|
1725
|
+
>>> a
|
1726
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1727
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1728
|
+
[0, 0, 1, 3, 1, 0, 0],
|
1729
|
+
[0, 0, 1, 1, 1, 0, 0],
|
1730
|
+
[0, 0, 1, 1, 2, 0, 0],
|
1731
|
+
[0, 0, 0, 0, 0, 0, 0],
|
1732
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1733
|
+
>>> ndimage.morphological_gradient(a, size=(3,3))
|
1734
|
+
array([[0, 0, 0, 0, 0, 0, 0],
|
1735
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1736
|
+
[0, 1, 3, 3, 3, 1, 0],
|
1737
|
+
[0, 1, 3, 2, 3, 2, 0],
|
1738
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1739
|
+
[0, 1, 1, 2, 2, 2, 0],
|
1740
|
+
[0, 0, 0, 0, 0, 0, 0]])
|
1741
|
+
|
1742
|
+
"""
|
1743
|
+
tmp = grey_dilation(input, size, footprint, structure, None, mode,
|
1744
|
+
cval, origin, axes=axes)
|
1745
|
+
if isinstance(output, np.ndarray):
|
1746
|
+
grey_erosion(input, size, footprint, structure, output, mode,
|
1747
|
+
cval, origin, axes=axes)
|
1748
|
+
return np.subtract(tmp, output, output)
|
1749
|
+
else:
|
1750
|
+
return (tmp - grey_erosion(input, size, footprint, structure,
|
1751
|
+
None, mode, cval, origin, axes=axes))
|
1752
|
+
|
1753
|
+
|
1754
|
+
def morphological_laplace(input, size=None, footprint=None, structure=None,
|
1755
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1756
|
+
axes=None):
|
1757
|
+
"""
|
1758
|
+
Multidimensional morphological laplace.
|
1759
|
+
|
1760
|
+
Parameters
|
1761
|
+
----------
|
1762
|
+
input : array_like
|
1763
|
+
Input.
|
1764
|
+
size : tuple of ints
|
1765
|
+
Shape of a flat and full structuring element used for the mathematical
|
1766
|
+
morphology operations. Optional if `footprint` or `structure` is
|
1767
|
+
provided.
|
1768
|
+
footprint : array of ints, optional
|
1769
|
+
Positions of non-infinite elements of a flat structuring element
|
1770
|
+
used for the morphology operations.
|
1771
|
+
structure : array of ints, optional
|
1772
|
+
Structuring element used for the morphology operations. `structure` may
|
1773
|
+
be a non-flat structuring element. The `structure` array applies
|
1774
|
+
offsets to the pixels in a neighborhood (the offset is additive during
|
1775
|
+
dilation and subtractive during erosion)
|
1776
|
+
output : ndarray, optional
|
1777
|
+
An output array can optionally be provided.
|
1778
|
+
mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
|
1779
|
+
The mode parameter determines how the array borders are handled.
|
1780
|
+
For 'constant' mode, values beyond borders are set to be `cval`.
|
1781
|
+
Default is 'reflect'.
|
1782
|
+
cval : scalar, optional
|
1783
|
+
Value to fill past edges of input if mode is 'constant'.
|
1784
|
+
Default is 0.0
|
1785
|
+
origin : origin, optional
|
1786
|
+
The origin parameter controls the placement of the filter.
|
1787
|
+
axes : tuple of int or None
|
1788
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1789
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1790
|
+
the number of axes.
|
1791
|
+
|
1792
|
+
Returns
|
1793
|
+
-------
|
1794
|
+
morphological_laplace : ndarray
|
1795
|
+
Output
|
1796
|
+
|
1797
|
+
"""
|
1798
|
+
input = np.asarray(input)
|
1799
|
+
tmp1 = grey_dilation(input, size, footprint, structure, None, mode,
|
1800
|
+
cval, origin, axes=axes)
|
1801
|
+
if isinstance(output, np.ndarray):
|
1802
|
+
grey_erosion(input, size, footprint, structure, output, mode,
|
1803
|
+
cval, origin, axes=axes)
|
1804
|
+
np.add(tmp1, output, output)
|
1805
|
+
np.subtract(output, input, output)
|
1806
|
+
return np.subtract(output, input, output)
|
1807
|
+
else:
|
1808
|
+
tmp2 = grey_erosion(input, size, footprint, structure, None, mode,
|
1809
|
+
cval, origin, axes=axes)
|
1810
|
+
np.add(tmp1, tmp2, tmp2)
|
1811
|
+
np.subtract(tmp2, input, tmp2)
|
1812
|
+
np.subtract(tmp2, input, tmp2)
|
1813
|
+
return tmp2
|
1814
|
+
|
1815
|
+
|
1816
|
+
def white_tophat(input, size=None, footprint=None, structure=None,
|
1817
|
+
output=None, mode="reflect", cval=0.0, origin=0, *,
|
1818
|
+
axes=None):
|
1819
|
+
"""
|
1820
|
+
Multidimensional white tophat filter.
|
1821
|
+
|
1822
|
+
Parameters
|
1823
|
+
----------
|
1824
|
+
input : array_like
|
1825
|
+
Input.
|
1826
|
+
size : tuple of ints
|
1827
|
+
Shape of a flat and full structuring element used for the filter.
|
1828
|
+
Optional if `footprint` or `structure` is provided.
|
1829
|
+
footprint : array of ints, optional
|
1830
|
+
Positions of elements of a flat structuring element
|
1831
|
+
used for the white tophat filter.
|
1832
|
+
structure : array of ints, optional
|
1833
|
+
Structuring element used for the filter. `structure` may be a non-flat
|
1834
|
+
structuring element. The `structure` array applies offsets to the
|
1835
|
+
pixels in a neighborhood (the offset is additive during dilation and
|
1836
|
+
subtractive during erosion)
|
1837
|
+
output : array, optional
|
1838
|
+
An array used for storing the output of the filter may be provided.
|
1839
|
+
mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
|
1840
|
+
The `mode` parameter determines how the array borders are
|
1841
|
+
handled, where `cval` is the value when mode is equal to
|
1842
|
+
'constant'. Default is 'reflect'
|
1843
|
+
cval : scalar, optional
|
1844
|
+
Value to fill past edges of input if `mode` is 'constant'.
|
1845
|
+
Default is 0.0.
|
1846
|
+
origin : scalar, optional
|
1847
|
+
The `origin` parameter controls the placement of the filter.
|
1848
|
+
Default is 0.
|
1849
|
+
axes : tuple of int or None
|
1850
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1851
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1852
|
+
the number of axes.
|
1853
|
+
|
1854
|
+
Returns
|
1855
|
+
-------
|
1856
|
+
output : ndarray
|
1857
|
+
Result of the filter of `input` with `structure`.
|
1858
|
+
|
1859
|
+
See Also
|
1860
|
+
--------
|
1861
|
+
black_tophat
|
1862
|
+
|
1863
|
+
Examples
|
1864
|
+
--------
|
1865
|
+
Subtract gray background from a bright peak.
|
1866
|
+
|
1867
|
+
>>> from scipy.ndimage import generate_binary_structure, white_tophat
|
1868
|
+
>>> import numpy as np
|
1869
|
+
>>> square = generate_binary_structure(rank=2, connectivity=3)
|
1870
|
+
>>> bright_on_gray = np.array([[2, 3, 3, 3, 2],
|
1871
|
+
... [3, 4, 5, 4, 3],
|
1872
|
+
... [3, 5, 9, 5, 3],
|
1873
|
+
... [3, 4, 5, 4, 3],
|
1874
|
+
... [2, 3, 3, 3, 2]])
|
1875
|
+
>>> white_tophat(input=bright_on_gray, structure=square)
|
1876
|
+
array([[0, 0, 0, 0, 0],
|
1877
|
+
[0, 0, 1, 0, 0],
|
1878
|
+
[0, 1, 5, 1, 0],
|
1879
|
+
[0, 0, 1, 0, 0],
|
1880
|
+
[0, 0, 0, 0, 0]])
|
1881
|
+
|
1882
|
+
"""
|
1883
|
+
input = np.asarray(input)
|
1884
|
+
|
1885
|
+
if (size is not None) and (footprint is not None):
|
1886
|
+
warnings.warn("ignoring size because footprint is set",
|
1887
|
+
UserWarning, stacklevel=2)
|
1888
|
+
tmp = grey_erosion(input, size, footprint, structure, None, mode,
|
1889
|
+
cval, origin, axes=axes)
|
1890
|
+
tmp = grey_dilation(tmp, size, footprint, structure, output, mode,
|
1891
|
+
cval, origin, axes=axes)
|
1892
|
+
if tmp is None:
|
1893
|
+
tmp = output
|
1894
|
+
|
1895
|
+
if input.dtype == np.bool_ and tmp.dtype == np.bool_:
|
1896
|
+
np.bitwise_xor(input, tmp, out=tmp)
|
1897
|
+
else:
|
1898
|
+
np.subtract(input, tmp, out=tmp)
|
1899
|
+
return tmp
|
1900
|
+
|
1901
|
+
|
1902
|
+
def black_tophat(input, size=None, footprint=None, structure=None, output=None,
|
1903
|
+
mode="reflect", cval=0.0, origin=0, *, axes=None):
|
1904
|
+
"""
|
1905
|
+
Multidimensional black tophat filter.
|
1906
|
+
|
1907
|
+
Parameters
|
1908
|
+
----------
|
1909
|
+
input : array_like
|
1910
|
+
Input.
|
1911
|
+
size : tuple of ints, optional
|
1912
|
+
Shape of a flat and full structuring element used for the filter.
|
1913
|
+
Optional if `footprint` or `structure` is provided.
|
1914
|
+
footprint : array of ints, optional
|
1915
|
+
Positions of non-infinite elements of a flat structuring element
|
1916
|
+
used for the black tophat filter.
|
1917
|
+
structure : array of ints, optional
|
1918
|
+
Structuring element used for the filter. `structure` may be a non-flat
|
1919
|
+
structuring element. The `structure` array applies offsets to the
|
1920
|
+
pixels in a neighborhood (the offset is additive during dilation and
|
1921
|
+
subtractive during erosion)
|
1922
|
+
output : array, optional
|
1923
|
+
An array used for storing the output of the filter may be provided.
|
1924
|
+
mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
|
1925
|
+
The `mode` parameter determines how the array borders are
|
1926
|
+
handled, where `cval` is the value when mode is equal to
|
1927
|
+
'constant'. Default is 'reflect'
|
1928
|
+
cval : scalar, optional
|
1929
|
+
Value to fill past edges of input if `mode` is 'constant'. Default
|
1930
|
+
is 0.0.
|
1931
|
+
origin : scalar, optional
|
1932
|
+
The `origin` parameter controls the placement of the filter.
|
1933
|
+
Default 0
|
1934
|
+
axes : tuple of int or None
|
1935
|
+
The axes over which to apply the filter. If None, `input` is filtered
|
1936
|
+
along all axes. If an `origin` tuple is provided, its length must match
|
1937
|
+
the number of axes.
|
1938
|
+
|
1939
|
+
Returns
|
1940
|
+
-------
|
1941
|
+
black_tophat : ndarray
|
1942
|
+
Result of the filter of `input` with `structure`.
|
1943
|
+
|
1944
|
+
See Also
|
1945
|
+
--------
|
1946
|
+
white_tophat, grey_opening, grey_closing
|
1947
|
+
|
1948
|
+
Examples
|
1949
|
+
--------
|
1950
|
+
Change dark peak to bright peak and subtract background.
|
1951
|
+
|
1952
|
+
>>> from scipy.ndimage import generate_binary_structure, black_tophat
|
1953
|
+
>>> import numpy as np
|
1954
|
+
>>> square = generate_binary_structure(rank=2, connectivity=3)
|
1955
|
+
>>> dark_on_gray = np.array([[7, 6, 6, 6, 7],
|
1956
|
+
... [6, 5, 4, 5, 6],
|
1957
|
+
... [6, 4, 0, 4, 6],
|
1958
|
+
... [6, 5, 4, 5, 6],
|
1959
|
+
... [7, 6, 6, 6, 7]])
|
1960
|
+
>>> black_tophat(input=dark_on_gray, structure=square)
|
1961
|
+
array([[0, 0, 0, 0, 0],
|
1962
|
+
[0, 0, 1, 0, 0],
|
1963
|
+
[0, 1, 5, 1, 0],
|
1964
|
+
[0, 0, 1, 0, 0],
|
1965
|
+
[0, 0, 0, 0, 0]])
|
1966
|
+
|
1967
|
+
"""
|
1968
|
+
input = np.asarray(input)
|
1969
|
+
|
1970
|
+
if (size is not None) and (footprint is not None):
|
1971
|
+
warnings.warn("ignoring size because footprint is set",
|
1972
|
+
UserWarning, stacklevel=2)
|
1973
|
+
tmp = grey_dilation(input, size, footprint, structure, None, mode,
|
1974
|
+
cval, origin, axes=axes)
|
1975
|
+
tmp = grey_erosion(tmp, size, footprint, structure, output, mode,
|
1976
|
+
cval, origin, axes=axes)
|
1977
|
+
if tmp is None:
|
1978
|
+
tmp = output
|
1979
|
+
|
1980
|
+
if input.dtype == np.bool_ and tmp.dtype == np.bool_:
|
1981
|
+
np.bitwise_xor(tmp, input, out=tmp)
|
1982
|
+
else:
|
1983
|
+
np.subtract(tmp, input, out=tmp)
|
1984
|
+
return tmp
|
1985
|
+
|
1986
|
+
|
1987
|
+
def distance_transform_bf(input, metric="euclidean", sampling=None,
|
1988
|
+
return_distances=True, return_indices=False,
|
1989
|
+
distances=None, indices=None):
|
1990
|
+
"""
|
1991
|
+
Distance transform function by a brute force algorithm.
|
1992
|
+
|
1993
|
+
This function calculates the distance transform of the `input`, by
|
1994
|
+
replacing each foreground (non-zero) element, with its
|
1995
|
+
shortest distance to the background (any zero-valued element).
|
1996
|
+
|
1997
|
+
In addition to the distance transform, the feature transform can
|
1998
|
+
be calculated. In this case the index of the closest background
|
1999
|
+
element to each foreground element is returned in a separate array.
|
2000
|
+
|
2001
|
+
Parameters
|
2002
|
+
----------
|
2003
|
+
input : array_like
|
2004
|
+
Input
|
2005
|
+
metric : {'euclidean', 'taxicab', 'chessboard'}, optional
|
2006
|
+
'cityblock' and 'manhattan' are also valid, and map to 'taxicab'.
|
2007
|
+
The default is 'euclidean'.
|
2008
|
+
sampling : float, or sequence of float, optional
|
2009
|
+
This parameter is only used when `metric` is 'euclidean'.
|
2010
|
+
Spacing of elements along each dimension. If a sequence, must be of
|
2011
|
+
length equal to the input rank; if a single number, this is used for
|
2012
|
+
all axes. If not specified, a grid spacing of unity is implied.
|
2013
|
+
return_distances : bool, optional
|
2014
|
+
Whether to calculate the distance transform.
|
2015
|
+
Default is True.
|
2016
|
+
return_indices : bool, optional
|
2017
|
+
Whether to calculate the feature transform.
|
2018
|
+
Default is False.
|
2019
|
+
distances : ndarray, optional
|
2020
|
+
An output array to store the calculated distance transform, instead of
|
2021
|
+
returning it.
|
2022
|
+
`return_distances` must be True.
|
2023
|
+
It must be the same shape as `input`, and of type float64 if `metric`
|
2024
|
+
is 'euclidean', uint32 otherwise.
|
2025
|
+
indices : int32 ndarray, optional
|
2026
|
+
An output array to store the calculated feature transform, instead of
|
2027
|
+
returning it.
|
2028
|
+
`return_indicies` must be True.
|
2029
|
+
Its shape must be ``(input.ndim,) + input.shape``.
|
2030
|
+
|
2031
|
+
Returns
|
2032
|
+
-------
|
2033
|
+
distances : ndarray, optional
|
2034
|
+
The calculated distance transform. Returned only when
|
2035
|
+
`return_distances` is True and `distances` is not supplied.
|
2036
|
+
It will have the same shape as the input array.
|
2037
|
+
indices : int32 ndarray, optional
|
2038
|
+
The calculated feature transform. It has an input-shaped array for each
|
2039
|
+
dimension of the input. See distance_transform_edt documentation for an
|
2040
|
+
example.
|
2041
|
+
Returned only when `return_indices` is True and `indices` is not
|
2042
|
+
supplied.
|
2043
|
+
|
2044
|
+
See Also
|
2045
|
+
--------
|
2046
|
+
distance_transform_cdt : Faster distance transform for taxicab and
|
2047
|
+
chessboard metrics
|
2048
|
+
distance_transform_edt : Faster distance transform for euclidean metric
|
2049
|
+
|
2050
|
+
Notes
|
2051
|
+
-----
|
2052
|
+
This function employs a slow brute force algorithm. See also the
|
2053
|
+
function `distance_transform_cdt` for more efficient taxicab [1]_ and
|
2054
|
+
chessboard algorithms [2]_.
|
2055
|
+
|
2056
|
+
References
|
2057
|
+
----------
|
2058
|
+
.. [1] Taxicab distance. Wikipedia, 2023.
|
2059
|
+
https://en.wikipedia.org/wiki/Taxicab_geometry
|
2060
|
+
.. [2] Chessboard distance. Wikipedia, 2023.
|
2061
|
+
https://en.wikipedia.org/wiki/Chebyshev_distance
|
2062
|
+
|
2063
|
+
Examples
|
2064
|
+
--------
|
2065
|
+
Import the necessary modules.
|
2066
|
+
|
2067
|
+
>>> import numpy as np
|
2068
|
+
>>> from scipy.ndimage import distance_transform_bf
|
2069
|
+
>>> import matplotlib.pyplot as plt
|
2070
|
+
>>> from mpl_toolkits.axes_grid1 import ImageGrid
|
2071
|
+
|
2072
|
+
First, we create a toy binary image.
|
2073
|
+
|
2074
|
+
>>> def add_circle(center_x, center_y, radius, image, fillvalue=1):
|
2075
|
+
... # fill circular area with 1
|
2076
|
+
... xx, yy = np.mgrid[:image.shape[0], :image.shape[1]]
|
2077
|
+
... circle = (xx - center_x) ** 2 + (yy - center_y) ** 2
|
2078
|
+
... circle_shape = np.sqrt(circle) < radius
|
2079
|
+
... image[circle_shape] = fillvalue
|
2080
|
+
... return image
|
2081
|
+
>>> image = np.zeros((100, 100), dtype=np.uint8)
|
2082
|
+
>>> image[35:65, 20:80] = 1
|
2083
|
+
>>> image = add_circle(28, 65, 10, image)
|
2084
|
+
>>> image = add_circle(37, 30, 10, image)
|
2085
|
+
>>> image = add_circle(70, 45, 20, image)
|
2086
|
+
>>> image = add_circle(45, 80, 10, image)
|
2087
|
+
|
2088
|
+
Next, we set up the figure.
|
2089
|
+
|
2090
|
+
>>> fig = plt.figure(figsize=(8, 8)) # set up the figure structure
|
2091
|
+
>>> grid = ImageGrid(fig, 111, nrows_ncols=(2, 2), axes_pad=(0.4, 0.3),
|
2092
|
+
... label_mode="1", share_all=True,
|
2093
|
+
... cbar_location="right", cbar_mode="each",
|
2094
|
+
... cbar_size="7%", cbar_pad="2%")
|
2095
|
+
>>> for ax in grid:
|
2096
|
+
... ax.axis('off') # remove axes from images
|
2097
|
+
|
2098
|
+
The top left image is the original binary image.
|
2099
|
+
|
2100
|
+
>>> binary_image = grid[0].imshow(image, cmap='gray')
|
2101
|
+
>>> cbar_binary_image = grid.cbar_axes[0].colorbar(binary_image)
|
2102
|
+
>>> cbar_binary_image.set_ticks([0, 1])
|
2103
|
+
>>> grid[0].set_title("Binary image: foreground in white")
|
2104
|
+
|
2105
|
+
The distance transform calculates the distance between foreground pixels
|
2106
|
+
and the image background according to a distance metric. Available metrics
|
2107
|
+
in `distance_transform_bf` are: ``euclidean`` (default), ``taxicab``
|
2108
|
+
and ``chessboard``. The top right image contains the distance transform
|
2109
|
+
based on the ``euclidean`` metric.
|
2110
|
+
|
2111
|
+
>>> distance_transform_euclidean = distance_transform_bf(image)
|
2112
|
+
>>> euclidean_transform = grid[1].imshow(distance_transform_euclidean,
|
2113
|
+
... cmap='gray')
|
2114
|
+
>>> cbar_euclidean = grid.cbar_axes[1].colorbar(euclidean_transform)
|
2115
|
+
>>> colorbar_ticks = [0, 10, 20]
|
2116
|
+
>>> cbar_euclidean.set_ticks(colorbar_ticks)
|
2117
|
+
>>> grid[1].set_title("Euclidean distance")
|
2118
|
+
|
2119
|
+
The lower left image contains the distance transform using the ``taxicab``
|
2120
|
+
metric.
|
2121
|
+
|
2122
|
+
>>> distance_transform_taxicab = distance_transform_bf(image,
|
2123
|
+
... metric='taxicab')
|
2124
|
+
>>> taxicab_transformation = grid[2].imshow(distance_transform_taxicab,
|
2125
|
+
... cmap='gray')
|
2126
|
+
>>> cbar_taxicab = grid.cbar_axes[2].colorbar(taxicab_transformation)
|
2127
|
+
>>> cbar_taxicab.set_ticks(colorbar_ticks)
|
2128
|
+
>>> grid[2].set_title("Taxicab distance")
|
2129
|
+
|
2130
|
+
Finally, the lower right image contains the distance transform using the
|
2131
|
+
``chessboard`` metric.
|
2132
|
+
|
2133
|
+
>>> distance_transform_cb = distance_transform_bf(image,
|
2134
|
+
... metric='chessboard')
|
2135
|
+
>>> chessboard_transformation = grid[3].imshow(distance_transform_cb,
|
2136
|
+
... cmap='gray')
|
2137
|
+
>>> cbar_taxicab = grid.cbar_axes[3].colorbar(chessboard_transformation)
|
2138
|
+
>>> cbar_taxicab.set_ticks(colorbar_ticks)
|
2139
|
+
>>> grid[3].set_title("Chessboard distance")
|
2140
|
+
>>> plt.show()
|
2141
|
+
|
2142
|
+
"""
|
2143
|
+
ft_inplace = isinstance(indices, np.ndarray)
|
2144
|
+
dt_inplace = isinstance(distances, np.ndarray)
|
2145
|
+
_distance_tranform_arg_check(
|
2146
|
+
dt_inplace, ft_inplace, return_distances, return_indices
|
2147
|
+
)
|
2148
|
+
|
2149
|
+
tmp1 = np.asarray(input) != 0
|
2150
|
+
struct = generate_binary_structure(tmp1.ndim, tmp1.ndim)
|
2151
|
+
tmp2 = binary_dilation(tmp1, struct)
|
2152
|
+
tmp2 = np.logical_xor(tmp1, tmp2)
|
2153
|
+
tmp1 = tmp1.astype(np.int8) - tmp2.astype(np.int8)
|
2154
|
+
metric = metric.lower()
|
2155
|
+
if metric == 'euclidean':
|
2156
|
+
metric = 1
|
2157
|
+
elif metric in ['taxicab', 'cityblock', 'manhattan']:
|
2158
|
+
metric = 2
|
2159
|
+
elif metric == 'chessboard':
|
2160
|
+
metric = 3
|
2161
|
+
else:
|
2162
|
+
raise RuntimeError('distance metric not supported')
|
2163
|
+
if sampling is not None:
|
2164
|
+
sampling = _ni_support._normalize_sequence(sampling, tmp1.ndim)
|
2165
|
+
sampling = np.asarray(sampling, dtype=np.float64)
|
2166
|
+
if not sampling.flags.contiguous:
|
2167
|
+
sampling = sampling.copy()
|
2168
|
+
if return_indices:
|
2169
|
+
ft = np.zeros(tmp1.shape, dtype=np.int32)
|
2170
|
+
else:
|
2171
|
+
ft = None
|
2172
|
+
if return_distances:
|
2173
|
+
if distances is None:
|
2174
|
+
if metric == 1:
|
2175
|
+
dt = np.zeros(tmp1.shape, dtype=np.float64)
|
2176
|
+
else:
|
2177
|
+
dt = np.zeros(tmp1.shape, dtype=np.uint32)
|
2178
|
+
else:
|
2179
|
+
if distances.shape != tmp1.shape:
|
2180
|
+
raise RuntimeError('distances array has wrong shape')
|
2181
|
+
if metric == 1:
|
2182
|
+
if distances.dtype.type != np.float64:
|
2183
|
+
raise RuntimeError('distances array must be float64')
|
2184
|
+
else:
|
2185
|
+
if distances.dtype.type != np.uint32:
|
2186
|
+
raise RuntimeError('distances array must be uint32')
|
2187
|
+
dt = distances
|
2188
|
+
else:
|
2189
|
+
dt = None
|
2190
|
+
|
2191
|
+
_nd_image.distance_transform_bf(tmp1, metric, sampling, dt, ft)
|
2192
|
+
if return_indices:
|
2193
|
+
if isinstance(indices, np.ndarray):
|
2194
|
+
if indices.dtype.type != np.int32:
|
2195
|
+
raise RuntimeError('indices array must be int32')
|
2196
|
+
if indices.shape != (tmp1.ndim,) + tmp1.shape:
|
2197
|
+
raise RuntimeError('indices array has wrong shape')
|
2198
|
+
tmp2 = indices
|
2199
|
+
else:
|
2200
|
+
tmp2 = np.indices(tmp1.shape, dtype=np.int32)
|
2201
|
+
ft = np.ravel(ft)
|
2202
|
+
for ii in range(tmp2.shape[0]):
|
2203
|
+
rtmp = np.ravel(tmp2[ii, ...])[ft]
|
2204
|
+
rtmp.shape = tmp1.shape
|
2205
|
+
tmp2[ii, ...] = rtmp
|
2206
|
+
ft = tmp2
|
2207
|
+
|
2208
|
+
# construct and return the result
|
2209
|
+
result = []
|
2210
|
+
if return_distances and not dt_inplace:
|
2211
|
+
result.append(dt)
|
2212
|
+
if return_indices and not ft_inplace:
|
2213
|
+
result.append(ft)
|
2214
|
+
|
2215
|
+
if len(result) == 2:
|
2216
|
+
return tuple(result)
|
2217
|
+
elif len(result) == 1:
|
2218
|
+
return result[0]
|
2219
|
+
else:
|
2220
|
+
return None
|
2221
|
+
|
2222
|
+
|
2223
|
+
def distance_transform_cdt(input, metric='chessboard', return_distances=True,
|
2224
|
+
return_indices=False, distances=None, indices=None):
|
2225
|
+
"""
|
2226
|
+
Distance transform for chamfer type of transforms.
|
2227
|
+
|
2228
|
+
This function calculates the distance transform of the `input`, by
|
2229
|
+
replacing each foreground (non-zero) element, with its
|
2230
|
+
shortest distance to the background (any zero-valued element).
|
2231
|
+
|
2232
|
+
In addition to the distance transform, the feature transform can
|
2233
|
+
be calculated. In this case the index of the closest background
|
2234
|
+
element to each foreground element is returned in a separate array.
|
2235
|
+
|
2236
|
+
Parameters
|
2237
|
+
----------
|
2238
|
+
input : array_like
|
2239
|
+
Input. Values of 0 are treated as background.
|
2240
|
+
metric : {'chessboard', 'taxicab'} or array_like, optional
|
2241
|
+
The `metric` determines the type of chamfering that is done. If the
|
2242
|
+
`metric` is equal to 'taxicab' a structure is generated using
|
2243
|
+
`generate_binary_structure` with a squared distance equal to 1. If
|
2244
|
+
the `metric` is equal to 'chessboard', a `metric` is generated
|
2245
|
+
using `generate_binary_structure` with a squared distance equal to
|
2246
|
+
the dimensionality of the array. These choices correspond to the
|
2247
|
+
common interpretations of the 'taxicab' and the 'chessboard'
|
2248
|
+
distance metrics in two dimensions.
|
2249
|
+
A custom metric may be provided, in the form of a matrix where
|
2250
|
+
each dimension has a length of three.
|
2251
|
+
'cityblock' and 'manhattan' are also valid, and map to 'taxicab'.
|
2252
|
+
The default is 'chessboard'.
|
2253
|
+
return_distances : bool, optional
|
2254
|
+
Whether to calculate the distance transform.
|
2255
|
+
Default is True.
|
2256
|
+
return_indices : bool, optional
|
2257
|
+
Whether to calculate the feature transform.
|
2258
|
+
Default is False.
|
2259
|
+
distances : int32 ndarray, optional
|
2260
|
+
An output array to store the calculated distance transform, instead of
|
2261
|
+
returning it.
|
2262
|
+
`return_distances` must be True.
|
2263
|
+
It must be the same shape as `input`.
|
2264
|
+
indices : int32 ndarray, optional
|
2265
|
+
An output array to store the calculated feature transform, instead of
|
2266
|
+
returning it.
|
2267
|
+
`return_indicies` must be True.
|
2268
|
+
Its shape must be ``(input.ndim,) + input.shape``.
|
2269
|
+
|
2270
|
+
Returns
|
2271
|
+
-------
|
2272
|
+
distances : int32 ndarray, optional
|
2273
|
+
The calculated distance transform. Returned only when
|
2274
|
+
`return_distances` is True, and `distances` is not supplied.
|
2275
|
+
It will have the same shape as the input array.
|
2276
|
+
indices : int32 ndarray, optional
|
2277
|
+
The calculated feature transform. It has an input-shaped array for each
|
2278
|
+
dimension of the input. See distance_transform_edt documentation for an
|
2279
|
+
example.
|
2280
|
+
Returned only when `return_indices` is True, and `indices` is not
|
2281
|
+
supplied.
|
2282
|
+
|
2283
|
+
See Also
|
2284
|
+
--------
|
2285
|
+
distance_transform_edt : Fast distance transform for euclidean metric
|
2286
|
+
distance_transform_bf : Distance transform for different metrics using
|
2287
|
+
a slower brute force algorithm
|
2288
|
+
|
2289
|
+
Examples
|
2290
|
+
--------
|
2291
|
+
Import the necessary modules.
|
2292
|
+
|
2293
|
+
>>> import numpy as np
|
2294
|
+
>>> from scipy.ndimage import distance_transform_cdt
|
2295
|
+
>>> import matplotlib.pyplot as plt
|
2296
|
+
>>> from mpl_toolkits.axes_grid1 import ImageGrid
|
2297
|
+
|
2298
|
+
First, we create a toy binary image.
|
2299
|
+
|
2300
|
+
>>> def add_circle(center_x, center_y, radius, image, fillvalue=1):
|
2301
|
+
... # fill circular area with 1
|
2302
|
+
... xx, yy = np.mgrid[:image.shape[0], :image.shape[1]]
|
2303
|
+
... circle = (xx - center_x) ** 2 + (yy - center_y) ** 2
|
2304
|
+
... circle_shape = np.sqrt(circle) < radius
|
2305
|
+
... image[circle_shape] = fillvalue
|
2306
|
+
... return image
|
2307
|
+
>>> image = np.zeros((100, 100), dtype=np.uint8)
|
2308
|
+
>>> image[35:65, 20:80] = 1
|
2309
|
+
>>> image = add_circle(28, 65, 10, image)
|
2310
|
+
>>> image = add_circle(37, 30, 10, image)
|
2311
|
+
>>> image = add_circle(70, 45, 20, image)
|
2312
|
+
>>> image = add_circle(45, 80, 10, image)
|
2313
|
+
|
2314
|
+
Next, we set up the figure.
|
2315
|
+
|
2316
|
+
>>> fig = plt.figure(figsize=(5, 15))
|
2317
|
+
>>> grid = ImageGrid(fig, 111, nrows_ncols=(3, 1), axes_pad=(0.5, 0.3),
|
2318
|
+
... label_mode="1", share_all=True,
|
2319
|
+
... cbar_location="right", cbar_mode="each",
|
2320
|
+
... cbar_size="7%", cbar_pad="2%")
|
2321
|
+
>>> for ax in grid:
|
2322
|
+
... ax.axis('off')
|
2323
|
+
>>> top, middle, bottom = grid
|
2324
|
+
>>> colorbar_ticks = [0, 10, 20]
|
2325
|
+
|
2326
|
+
The top image contains the original binary image.
|
2327
|
+
|
2328
|
+
>>> binary_image = top.imshow(image, cmap='gray')
|
2329
|
+
>>> cbar_binary_image = top.cax.colorbar(binary_image)
|
2330
|
+
>>> cbar_binary_image.set_ticks([0, 1])
|
2331
|
+
>>> top.set_title("Binary image: foreground in white")
|
2332
|
+
|
2333
|
+
The middle image contains the distance transform using the ``taxicab``
|
2334
|
+
metric.
|
2335
|
+
|
2336
|
+
>>> distance_taxicab = distance_transform_cdt(image, metric="taxicab")
|
2337
|
+
>>> taxicab_transform = middle.imshow(distance_taxicab, cmap='gray')
|
2338
|
+
>>> cbar_taxicab = middle.cax.colorbar(taxicab_transform)
|
2339
|
+
>>> cbar_taxicab.set_ticks(colorbar_ticks)
|
2340
|
+
>>> middle.set_title("Taxicab metric")
|
2341
|
+
|
2342
|
+
The bottom image contains the distance transform using the ``chessboard``
|
2343
|
+
metric.
|
2344
|
+
|
2345
|
+
>>> distance_chessboard = distance_transform_cdt(image,
|
2346
|
+
... metric="chessboard")
|
2347
|
+
>>> chessboard_transform = bottom.imshow(distance_chessboard, cmap='gray')
|
2348
|
+
>>> cbar_chessboard = bottom.cax.colorbar(chessboard_transform)
|
2349
|
+
>>> cbar_chessboard.set_ticks(colorbar_ticks)
|
2350
|
+
>>> bottom.set_title("Chessboard metric")
|
2351
|
+
>>> plt.tight_layout()
|
2352
|
+
>>> plt.show()
|
2353
|
+
|
2354
|
+
"""
|
2355
|
+
ft_inplace = isinstance(indices, np.ndarray)
|
2356
|
+
dt_inplace = isinstance(distances, np.ndarray)
|
2357
|
+
_distance_tranform_arg_check(
|
2358
|
+
dt_inplace, ft_inplace, return_distances, return_indices
|
2359
|
+
)
|
2360
|
+
input = np.asarray(input)
|
2361
|
+
if isinstance(metric, str):
|
2362
|
+
if metric in ['taxicab', 'cityblock', 'manhattan']:
|
2363
|
+
rank = input.ndim
|
2364
|
+
metric = generate_binary_structure(rank, 1)
|
2365
|
+
elif metric == 'chessboard':
|
2366
|
+
rank = input.ndim
|
2367
|
+
metric = generate_binary_structure(rank, rank)
|
2368
|
+
else:
|
2369
|
+
raise ValueError('invalid metric provided')
|
2370
|
+
else:
|
2371
|
+
try:
|
2372
|
+
metric = np.asarray(metric)
|
2373
|
+
except Exception as e:
|
2374
|
+
raise ValueError('invalid metric provided') from e
|
2375
|
+
for s in metric.shape:
|
2376
|
+
if s != 3:
|
2377
|
+
raise ValueError('metric sizes must be equal to 3')
|
2378
|
+
|
2379
|
+
if not metric.flags.contiguous:
|
2380
|
+
metric = metric.copy()
|
2381
|
+
if dt_inplace:
|
2382
|
+
if distances.dtype.type != np.int32:
|
2383
|
+
raise ValueError('distances must be of int32 type')
|
2384
|
+
if distances.shape != input.shape:
|
2385
|
+
raise ValueError('distances has wrong shape')
|
2386
|
+
dt = distances
|
2387
|
+
dt[...] = np.where(input, -1, 0).astype(np.int32)
|
2388
|
+
else:
|
2389
|
+
dt = np.where(input, -1, 0).astype(np.int32)
|
2390
|
+
|
2391
|
+
rank = dt.ndim
|
2392
|
+
if return_indices:
|
2393
|
+
ft = np.arange(dt.size, dtype=np.int32)
|
2394
|
+
ft.shape = dt.shape
|
2395
|
+
else:
|
2396
|
+
ft = None
|
2397
|
+
|
2398
|
+
_nd_image.distance_transform_op(metric, dt, ft)
|
2399
|
+
dt = dt[tuple([slice(None, None, -1)] * rank)]
|
2400
|
+
if return_indices:
|
2401
|
+
ft = ft[tuple([slice(None, None, -1)] * rank)]
|
2402
|
+
_nd_image.distance_transform_op(metric, dt, ft)
|
2403
|
+
dt = dt[tuple([slice(None, None, -1)] * rank)]
|
2404
|
+
if return_indices:
|
2405
|
+
ft = ft[tuple([slice(None, None, -1)] * rank)]
|
2406
|
+
ft = np.ravel(ft)
|
2407
|
+
if ft_inplace:
|
2408
|
+
if indices.dtype.type != np.int32:
|
2409
|
+
raise ValueError('indices array must be int32')
|
2410
|
+
if indices.shape != (dt.ndim,) + dt.shape:
|
2411
|
+
raise ValueError('indices array has wrong shape')
|
2412
|
+
tmp = indices
|
2413
|
+
else:
|
2414
|
+
tmp = np.indices(dt.shape, dtype=np.int32)
|
2415
|
+
for ii in range(tmp.shape[0]):
|
2416
|
+
rtmp = np.ravel(tmp[ii, ...])[ft]
|
2417
|
+
rtmp.shape = dt.shape
|
2418
|
+
tmp[ii, ...] = rtmp
|
2419
|
+
ft = tmp
|
2420
|
+
|
2421
|
+
# construct and return the result
|
2422
|
+
result = []
|
2423
|
+
if return_distances and not dt_inplace:
|
2424
|
+
result.append(dt)
|
2425
|
+
if return_indices and not ft_inplace:
|
2426
|
+
result.append(ft)
|
2427
|
+
|
2428
|
+
if len(result) == 2:
|
2429
|
+
return tuple(result)
|
2430
|
+
elif len(result) == 1:
|
2431
|
+
return result[0]
|
2432
|
+
else:
|
2433
|
+
return None
|
2434
|
+
|
2435
|
+
|
2436
|
+
def distance_transform_edt(input, sampling=None, return_distances=True,
|
2437
|
+
return_indices=False, distances=None, indices=None):
|
2438
|
+
"""
|
2439
|
+
Exact Euclidean distance transform.
|
2440
|
+
|
2441
|
+
This function calculates the distance transform of the `input`, by
|
2442
|
+
replacing each foreground (non-zero) element, with its
|
2443
|
+
shortest distance to the background (any zero-valued element).
|
2444
|
+
|
2445
|
+
In addition to the distance transform, the feature transform can
|
2446
|
+
be calculated. In this case the index of the closest background
|
2447
|
+
element to each foreground element is returned in a separate array.
|
2448
|
+
|
2449
|
+
Parameters
|
2450
|
+
----------
|
2451
|
+
input : array_like
|
2452
|
+
Input data to transform. Can be any type but will be converted
|
2453
|
+
into binary: 1 wherever input equates to True, 0 elsewhere.
|
2454
|
+
sampling : float, or sequence of float, optional
|
2455
|
+
Spacing of elements along each dimension. If a sequence, must be of
|
2456
|
+
length equal to the input rank; if a single number, this is used for
|
2457
|
+
all axes. If not specified, a grid spacing of unity is implied.
|
2458
|
+
return_distances : bool, optional
|
2459
|
+
Whether to calculate the distance transform.
|
2460
|
+
Default is True.
|
2461
|
+
return_indices : bool, optional
|
2462
|
+
Whether to calculate the feature transform.
|
2463
|
+
Default is False.
|
2464
|
+
distances : float64 ndarray, optional
|
2465
|
+
An output array to store the calculated distance transform, instead of
|
2466
|
+
returning it.
|
2467
|
+
`return_distances` must be True.
|
2468
|
+
It must be the same shape as `input`.
|
2469
|
+
indices : int32 ndarray, optional
|
2470
|
+
An output array to store the calculated feature transform, instead of
|
2471
|
+
returning it.
|
2472
|
+
`return_indicies` must be True.
|
2473
|
+
Its shape must be ``(input.ndim,) + input.shape``.
|
2474
|
+
|
2475
|
+
Returns
|
2476
|
+
-------
|
2477
|
+
distances : float64 ndarray, optional
|
2478
|
+
The calculated distance transform. Returned only when
|
2479
|
+
`return_distances` is True and `distances` is not supplied.
|
2480
|
+
It will have the same shape as the input array.
|
2481
|
+
indices : int32 ndarray, optional
|
2482
|
+
The calculated feature transform. It has an input-shaped array for each
|
2483
|
+
dimension of the input. See example below.
|
2484
|
+
Returned only when `return_indices` is True and `indices` is not
|
2485
|
+
supplied.
|
2486
|
+
|
2487
|
+
Notes
|
2488
|
+
-----
|
2489
|
+
The Euclidean distance transform gives values of the Euclidean
|
2490
|
+
distance::
|
2491
|
+
|
2492
|
+
n
|
2493
|
+
y_i = sqrt(sum (x[i]-b[i])**2)
|
2494
|
+
i
|
2495
|
+
|
2496
|
+
where b[i] is the background point (value 0) with the smallest
|
2497
|
+
Euclidean distance to input points x[i], and n is the
|
2498
|
+
number of dimensions.
|
2499
|
+
|
2500
|
+
Examples
|
2501
|
+
--------
|
2502
|
+
>>> from scipy import ndimage
|
2503
|
+
>>> import numpy as np
|
2504
|
+
>>> a = np.array(([0,1,1,1,1],
|
2505
|
+
... [0,0,1,1,1],
|
2506
|
+
... [0,1,1,1,1],
|
2507
|
+
... [0,1,1,1,0],
|
2508
|
+
... [0,1,1,0,0]))
|
2509
|
+
>>> ndimage.distance_transform_edt(a)
|
2510
|
+
array([[ 0. , 1. , 1.4142, 2.2361, 3. ],
|
2511
|
+
[ 0. , 0. , 1. , 2. , 2. ],
|
2512
|
+
[ 0. , 1. , 1.4142, 1.4142, 1. ],
|
2513
|
+
[ 0. , 1. , 1.4142, 1. , 0. ],
|
2514
|
+
[ 0. , 1. , 1. , 0. , 0. ]])
|
2515
|
+
|
2516
|
+
With a sampling of 2 units along x, 1 along y:
|
2517
|
+
|
2518
|
+
>>> ndimage.distance_transform_edt(a, sampling=[2,1])
|
2519
|
+
array([[ 0. , 1. , 2. , 2.8284, 3.6056],
|
2520
|
+
[ 0. , 0. , 1. , 2. , 3. ],
|
2521
|
+
[ 0. , 1. , 2. , 2.2361, 2. ],
|
2522
|
+
[ 0. , 1. , 2. , 1. , 0. ],
|
2523
|
+
[ 0. , 1. , 1. , 0. , 0. ]])
|
2524
|
+
|
2525
|
+
Asking for indices as well:
|
2526
|
+
|
2527
|
+
>>> edt, inds = ndimage.distance_transform_edt(a, return_indices=True)
|
2528
|
+
>>> inds
|
2529
|
+
array([[[0, 0, 1, 1, 3],
|
2530
|
+
[1, 1, 1, 1, 3],
|
2531
|
+
[2, 2, 1, 3, 3],
|
2532
|
+
[3, 3, 4, 4, 3],
|
2533
|
+
[4, 4, 4, 4, 4]],
|
2534
|
+
[[0, 0, 1, 1, 4],
|
2535
|
+
[0, 1, 1, 1, 4],
|
2536
|
+
[0, 0, 1, 4, 4],
|
2537
|
+
[0, 0, 3, 3, 4],
|
2538
|
+
[0, 0, 3, 3, 4]]], dtype=int32)
|
2539
|
+
|
2540
|
+
With arrays provided for inplace outputs:
|
2541
|
+
|
2542
|
+
>>> indices = np.zeros(((np.ndim(a),) + a.shape), dtype=np.int32)
|
2543
|
+
>>> ndimage.distance_transform_edt(a, return_indices=True, indices=indices)
|
2544
|
+
array([[ 0. , 1. , 1.4142, 2.2361, 3. ],
|
2545
|
+
[ 0. , 0. , 1. , 2. , 2. ],
|
2546
|
+
[ 0. , 1. , 1.4142, 1.4142, 1. ],
|
2547
|
+
[ 0. , 1. , 1.4142, 1. , 0. ],
|
2548
|
+
[ 0. , 1. , 1. , 0. , 0. ]])
|
2549
|
+
>>> indices
|
2550
|
+
array([[[0, 0, 1, 1, 3],
|
2551
|
+
[1, 1, 1, 1, 3],
|
2552
|
+
[2, 2, 1, 3, 3],
|
2553
|
+
[3, 3, 4, 4, 3],
|
2554
|
+
[4, 4, 4, 4, 4]],
|
2555
|
+
[[0, 0, 1, 1, 4],
|
2556
|
+
[0, 1, 1, 1, 4],
|
2557
|
+
[0, 0, 1, 4, 4],
|
2558
|
+
[0, 0, 3, 3, 4],
|
2559
|
+
[0, 0, 3, 3, 4]]], dtype=int32)
|
2560
|
+
|
2561
|
+
"""
|
2562
|
+
ft_inplace = isinstance(indices, np.ndarray)
|
2563
|
+
dt_inplace = isinstance(distances, np.ndarray)
|
2564
|
+
_distance_tranform_arg_check(
|
2565
|
+
dt_inplace, ft_inplace, return_distances, return_indices
|
2566
|
+
)
|
2567
|
+
|
2568
|
+
# calculate the feature transform
|
2569
|
+
input = np.atleast_1d(np.where(input, 1, 0).astype(np.int8))
|
2570
|
+
if sampling is not None:
|
2571
|
+
sampling = _ni_support._normalize_sequence(sampling, input.ndim)
|
2572
|
+
sampling = np.asarray(sampling, dtype=np.float64)
|
2573
|
+
if not sampling.flags.contiguous:
|
2574
|
+
sampling = sampling.copy()
|
2575
|
+
|
2576
|
+
if ft_inplace:
|
2577
|
+
ft = indices
|
2578
|
+
if ft.shape != (input.ndim,) + input.shape:
|
2579
|
+
raise RuntimeError('indices array has wrong shape')
|
2580
|
+
if ft.dtype.type != np.int32:
|
2581
|
+
raise RuntimeError('indices array must be int32')
|
2582
|
+
else:
|
2583
|
+
ft = np.zeros((input.ndim,) + input.shape, dtype=np.int32)
|
2584
|
+
|
2585
|
+
_nd_image.euclidean_feature_transform(input, sampling, ft)
|
2586
|
+
# if requested, calculate the distance transform
|
2587
|
+
if return_distances:
|
2588
|
+
dt = ft - np.indices(input.shape, dtype=ft.dtype)
|
2589
|
+
dt = dt.astype(np.float64)
|
2590
|
+
if sampling is not None:
|
2591
|
+
for ii in range(len(sampling)):
|
2592
|
+
dt[ii, ...] *= sampling[ii]
|
2593
|
+
np.multiply(dt, dt, dt)
|
2594
|
+
if dt_inplace:
|
2595
|
+
dt = np.add.reduce(dt, axis=0)
|
2596
|
+
if distances.shape != dt.shape:
|
2597
|
+
raise RuntimeError('distances array has wrong shape')
|
2598
|
+
if distances.dtype.type != np.float64:
|
2599
|
+
raise RuntimeError('distances array must be float64')
|
2600
|
+
np.sqrt(dt, distances)
|
2601
|
+
else:
|
2602
|
+
dt = np.add.reduce(dt, axis=0)
|
2603
|
+
dt = np.sqrt(dt)
|
2604
|
+
|
2605
|
+
# construct and return the result
|
2606
|
+
result = []
|
2607
|
+
if return_distances and not dt_inplace:
|
2608
|
+
result.append(dt)
|
2609
|
+
if return_indices and not ft_inplace:
|
2610
|
+
result.append(ft)
|
2611
|
+
|
2612
|
+
if len(result) == 2:
|
2613
|
+
return tuple(result)
|
2614
|
+
elif len(result) == 1:
|
2615
|
+
return result[0]
|
2616
|
+
else:
|
2617
|
+
return None
|
2618
|
+
|
2619
|
+
|
2620
|
+
def _distance_tranform_arg_check(distances_out, indices_out,
|
2621
|
+
return_distances, return_indices):
|
2622
|
+
"""Raise a RuntimeError if the arguments are invalid"""
|
2623
|
+
error_msgs = []
|
2624
|
+
if (not return_distances) and (not return_indices):
|
2625
|
+
error_msgs.append(
|
2626
|
+
'at least one of return_distances/return_indices must be True')
|
2627
|
+
if distances_out and not return_distances:
|
2628
|
+
error_msgs.append(
|
2629
|
+
'return_distances must be True if distances is supplied'
|
2630
|
+
)
|
2631
|
+
if indices_out and not return_indices:
|
2632
|
+
error_msgs.append('return_indices must be True if indices is supplied')
|
2633
|
+
if error_msgs:
|
2634
|
+
raise RuntimeError(', '.join(error_msgs))
|