資源簡介
這是一本基于python實現(xiàn)的BM3D去噪算法,值得學(xué)習(xí)一下

代碼片段和文件信息
“““PyBM3D?packaging?and?distribution.“““
import?os
from?setuptools?import?setup?Extension
from?setuptools.command.build_ext?import?build_ext?as?_build_ext
class?CustomBuildExt(_build_ext):
????“““Custom?build?extension?class.“““
????def?__init__(self?*args?**kwargs):
????????“““Extends?default?class?constructor.“““
????????#?_build_ext?is?not?a?new-style?(object)?class?which?is?required?for
????????#?super?to?work
????????_build_ext.__init__(self?*args?**kwargs)
????????self.cuda_config?=?self.load_cuda_config()
????def?build_extensions(self):
????????“““Extends?default?build_extensions?method.
????????Further?customizes?the?compiler?to?add?C?file?specific?compile
????????arguments?and?support?nvcc?compilation?of?*.cu?CUDA?files.“““
????????self.customize_compiler_for_c_args_and_nvcc()
????????_build_ext.build_extensions(self)
????def?finalize_options(self):
????????“““Extends?default?finalize_options?method.
????????Injects?NumPy‘s?C?include?directories?into?the?Cython?compilation.?This
????????is?done?after?NumPy?was?installed?through?the?setuptools?setup_requires
????????argument?which?removes?NumPy?from?the?necessary?preinstalled
????????packages.“““
????????_build_ext.finalize_options(self)
????????#?prevent?numpy?from?thinking?it?is?still?in?its?setup?process
????????__builtins__.__NUMPY_SETUP__?=?False
????????import?numpy
????????self.include_dirs.append(numpy.get_include())
????def?customize_compiler_for_c_args_and_nvcc(self):
????????“““Customize?the?compiler.
????????The?customization?adds?C?file?specific?compile
????????arguments?and?support?for?nvcc?compilation?of?*.cu?CUDA?files.“““
????????self.compiler.src_extensions.append(‘.cu‘)
????????#?save?references?to?the?default?compiler_so?and?_comple?methods
????????default_compiler_so?=?self.compiler.compiler_so
????????super?=?self.compiler._compile
????????#?now?redefine?the?_compile?method.?This?gets?executed?for?each
????????#?object?but?distutils?doesn‘t?have?the?ability?to?change?compilers
????????#?based?on?source?extension:?we?add?it.
????????def?_compile(obj?src?ext?cc_args?extra_postargs?pp_opts):
????????????if?os.path.splitext(src)[1]?==?‘.cu‘:
????????????????#?use?the?nvcc?for?*.cu?files
????????????????self.compiler.set_executable(‘compiler_so‘
?????????????????????????????????????????????self.cuda_config[‘nvcc‘])
????????????????postargs?=?extra_postargs[‘nvcc‘]
????????????else:
????????????????postargs?=?extra_postargs[‘unix‘]
????????????????#?add?C?file?specific?compile?arguments
????????????????if?os.path.splitext(src)[1]?==?‘.c‘:
????????????????????postargs?=?postargs?+?extra_postargs[‘c_args‘]
????????????super(obj?src?ext?cc_args?postargs?pp_opts)
????????????#?reset?the?default?compiler_so
????????????self.compiler.compiler_so?=?default_compiler_so
????????#?inject?our?redefined?_compile?method?into?the?class
????????self.compiler._compile?=?_compile
????@staticmethod
????def?load_cuda_config():
????????“““Locate?the?CUDA?env
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-09?10:23??pybm3d-0.2.1\
?????文件?????????278??2017-10-09?10:23??pybm3d-0.2.1\.gitignore
?????文件??????????84??2017-10-09?10:23??pybm3d-0.2.1\.gitmodules
?????文件?????????139??2017-10-09?10:23??pybm3d-0.2.1\.scrutinizer.yml
?????文件?????????841??2017-10-09?10:23??pybm3d-0.2.1\.travis.yml
?????文件???????35142??2017-10-09?10:23??pybm3d-0.2.1\LICENSE
?????文件??????????23??2017-10-09?10:23??pybm3d-0.2.1\MANIFEST.in
?????文件????????3939??2017-10-09?10:23??pybm3d-0.2.1\README.rst
?????目錄???????????0??2017-10-09?10:23??pybm3d-0.2.1\bm3d_src\
?????目錄???????????0??2017-10-09?10:23??pybm3d-0.2.1\pybm3d\
?????文件??????????90??2017-10-09?10:23??pybm3d-0.2.1\pybm3d\__init__.py
?????文件????????4594??2017-10-09?10:23??pybm3d-0.2.1\pybm3d\bm3d.pyx
?????文件?????????164??2017-10-09?10:23??pybm3d-0.2.1\setup.cfg
?????文件????????6004??2017-10-09?10:23??pybm3d-0.2.1\setup.py
?????目錄???????????0??2017-10-09?10:23??pybm3d-0.2.1\tests\
?????文件????????2639??2017-10-09?10:23??pybm3d-0.2.1\tests\test_bm3d.py
?????文件?????????502??2017-10-09?10:23??pybm3d-0.2.1\tox.ini
評論
共有 條評論