<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 3.3 Scikit-image:圖像處理 > **作者**: Emmanuelle Gouillart [scikit-image](http://scikit-image.org/)是專注于圖像處理的Python包,并且使用原生的Numpy數組作為圖像對象。本章描述如何在不同圖像處理任務上使用`scikit-image`,并且保留了其他科學Python模塊比如Numpy和Scipy的鏈接。 **也可以看一下:**對于基本圖像處理,比如圖像剪切或者簡單過濾,大量簡單操作可以用Numpy和SciPy來實現。看一下[使用Numpy和Scipy圖像操作和處理部分](http://www.scipy-lectures.org/advanced/image_processing/index.html#basic-image)。 注意,在閱讀本章之前你應該熟悉前面章節的內容,比如基礎操作,比如面具和標簽作為先決條件。 **章節內容** * **介紹和觀點** * `scikit-image` 和 `SciPy`生態系統 * `scikit-image`能發現什么 * **輸入/輸出, 數據類型和 顏色空間** * 數據類型 * 顏色空間 * **圖像預處理/增強** * 本地過濾器 * 非-本地過濾器 * 數學形態學 * **圖像細分** * 二元細分: 前景 + 背景 * 基于標記的方法 * **測量區域的屬性** * **數據可視化和交互** ## 3.3.1 介紹和觀點 圖像是NumPy的數組`np.ndarray` | 圖像: | np.ndarray | | --- | --- | | 像素: | array values: a[2, 3] | | 渠道: | array dimensions | | 圖像編碼: | dtype (np.uint8, np.uint16, np.float) | | 過濾器: | functions (numpy, skimage, scipy) | In?[1]: ``` %matplotlib inline import numpy as np check = np.zeros((9, 9)) check[::2, 1::2] = 1 check[1::2, ::2] = 1 import matplotlib.pyplot as plt plt.imshow(check, cmap='gray', interpolation='nearest') ``` Out[1]: ``` <matplotlib.image.AxesImage at 0x105717610> ``` ![](https://box.kancloud.cn/2016-03-21_56efdc0c28d57.png) ### 3.3.1.1 scikit-image 和 SciPy 生態系統 最新版的`scikit-image`包含在大多數的科學Python發行版中,比如,Anaconda或Enthought Canopy。它也包含在 Ubuntu/Debian。 In?[6]: ``` import skimage from skimage import data # 大多數函數在子包中 ``` 大多數`scikit-image`函數用NumPy ndarrays作為參數 In?[6]: ``` camera = data.camera() camera.dtype ``` Out[6]: ``` dtype('uint8') ``` In?[7]: ``` camera.shape ``` Out[7]: ``` (512, 512) ``` In?[8]: ``` from skimage import restoration filtered_camera = restoration.denoise_bilateral(camera) type(filtered_camera) ``` Out[8]: ``` numpy.ndarray ``` 其他Python包也可以用于圖像處理,并且使用Numpy數組: * [scipy.ndimage](http://docs.scipy.org/doc/scipy/reference/ndimage.html#module-scipy.ndimage) : 對于 nd-arrays。基礎過濾、數學形態學和區域屬性 * [Mahotas](http://luispedro.org/software/mahotas) 同時,強大的圖形處理庫有Python封裝: * [OpenCV](https://opencv-python-tutroals.readthedocs.org/en/latest/) (計算機視覺) * [ITK](http://www.itk.org/itkindex.html) (3D圖像和注冊) * 其他 (但是,他們沒有那么Pythonic也沒有Numpy友好,在一定范圍)。 ### 3.3.1.2 scikit-image能發現什么 * 網站: [http://scikit-image.org/](http://scikit-image.org/) * 例子庫 (就像在 [matplotlib](http://matplotlib.org/gallery.html) 或 [scikit-learn](http://scikit-learn.org/)): [http://scikit-image.org/docs/stable/auto_examples/](http://scikit-image.org/docs/stable/auto_examples/) 不同類的函數,從基本的使用函數到高級最新算法。 * 過濾器: 函數將圖像轉化為其他圖像。 * NumPy組件 * 通用過濾器算法 * 數據簡化函數: 計算圖像直方圖、局部極值位置、角。 * 其他動作: I/O, 可視化,等。 ## 3.3.2 輸入/輸出, 數據類型和顏色空間 I/O: [skimage.io](http://scikit-image.org/docs/stable/api/skimage.io.html#module-skimage.io) In?[4]: ``` from skimage import io ``` 讀取文件: [skimage.io.imread()](http://scikit-image.org/docs/stable/api/skimage.io.html#skimage.io.imread) In?[7]: ``` import os filename = os.path.join(skimage.data_dir, 'camera.png') camera = io.imread(filename) ``` ![](http://www.scipy-lectures.org/_images/plot_camera_1.png) 支持所有被Python Imaging Library(或者`imread` `plugin`關鍵詞提供的任何I/O插件)的數據格式。 也支持URL圖片路徑: In?[3]: ``` logo = io.imread('http://scikit-image.org/_static/img/logo.png') ``` 存儲文件: In?[4]: ``` io.imsave('local_logo.png', logo) ``` (`imsave`也用外部插件比如PIL) ### 3.3.2.1 數據類型 ![](http://www.scipy-lectures.org/_images/plot_camera_uint_1.png) 圖像ndarrays可以用整數(有符號或無符號)或浮點來代表。 小心整數類型的溢出 In?[8]: ``` camera = data.camera() camera.dtype ``` Out[8]: ``` dtype('uint8') ``` In?[8]: ``` camera_multiply = 3 * camera ``` 可用不同的整型大小: 8-, 16- 或 32-字節, 有符號或無符號。 一個重要的 (如果有疑問的話) `skimage` **慣例**: 圖像浮點支持在[-1, 1] (與所以浮點圖像相對) In?[9]: ``` from skimage import img_as_float camera_float = img_as_float(camera) camera.max(), camera_float.max() ``` Out[9]: ``` (255, 1.0) ``` 一些圖像處理程序需要應用在浮點數組上,因此,輸出的數組可能類型和數據范圍都與輸入數組不同 In?[9]: ``` try: from skimage import filters except ImportError: from skimage import filter as filters camera_sobel = filters.sobel(camera) camera_sobel.max() ``` Out[9]: ``` 0.5915023652179584 ``` 在上面的例子中,我們使用`scikit-image`的子模塊`filters`,在0.11到0.10版本間,`filter`被重命名為`filters`,為了避免與Python內置的`filter`沖突。 在[skimage](http://scikit-image.org/docs/stable/api/skimage.html#module-skimage)提供了下列skimage實用的函數來轉化dtype和data range: `util.img_as_float`、 `util.img_as_ubyte`等。 看一下[用戶手冊](http://scikit-image.org/docs/stable/user_guide/data_types.html)來了解細節。 In?[?]: ``` An important (if questionable) skimage convention: float images are supposed to lie in [-1, 1] (in order to have comparable contrast for all float images) ``` In?[?]: ``` 3.3.1. Introduction and concepts Images are NumPy’s arrays np.ndarray ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看