SciPy和Numpy处理能力
生活随笔
收集整理的這篇文章主要介紹了
SciPy和Numpy处理能力
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.SciPy和Numpy的處理能力:
numpy的處理能力包括:
- a powerful N-dimensional array object N維數組;
- advanced array slicing methods (to select array elements);N維數組的分片方法;
- convenient array reshaping methods;N維數組的變形方法;
and it even contains 3 libraries with numerical routines:
- basic linear algebra functions;基本線性代數函數;
- basic Fourier transforms;基本傅立葉變換;
- sophisticated random number capabilities;精巧的隨機數生成能力;
scipy是科學和工程計算工具。包括處理多維數組,多維數組可以是向量、矩陣、圖形(圖形圖像是像素的二維數組)、表格(一個表格是一個二維數組);目前能處理的對象有:
- statistics;統計學;
- numeric integration;數值積分;
- special functions;特殊函數;
- integration, ordinarydifferential equation (ODE) solvers;積分和解常微分方程;
- gradient optimization;梯度優化;
- geneticalgorithms;遺傳算法;
- parallel programming tools(an expression-to-C++ compilerfor fast execution, and others);并行編程工具;
在將來會增加下面的計算處理能力(現在已經部分地具備了這些能力):
- Circuit Analysis (wrapper around Spice?);電路分析;
- Micro-Electro Mechanical Systems simulators (MEMs);
- Medical image processing;醫學圖像處理;
- Neural networks;神經網絡;
- 3-D Visualization via VTK;3D可視化;
- Financial analysis;金融分析;
- Economic analysis;經濟分析;
- Hidden Markov Models;隱藏馬爾科夫模型;
2.處理圖像 翻譯鏈接:http://reverland.org/python/2012/11/12/numpyscipy/
原始鏈接:http://scipy-lectures.github.io/advanced/image_processing/index.html
特征提取和分形:
邊緣檢測
合成數據:
>>> im = np.zeros((256, 256)) >>> im[64:-64, 64:-64] = 1 >>> >>> im = ndimage.rotate(im, 15, mode='constant') >>> im = ndimage.gaussian_filter(im, 8)使用_梯度操作(Sobel)_來找到搞強度的變化:
>>> sx = ndimage.sobel(im, axis=0, mode='constant') >>> sy = ndimage.sobel(im, axis=1, mode='constant') >>> sob = np.hypot(sx, sy)示例源碼
canny濾鏡
Canny濾鏡可以從skimage中獲取(文檔),但是為了方便我們在這個教程中作為一個_單獨模塊_導入:
>>> #from skimage.filter import canny >>> #or use module shipped with tutorial >>> im += 0.1*np.random.random(im.shape) >>> edges = canny(im, 1, 0.4, 0.2) # not enough smoothing >>> edges = canny(im, 3, 0.3, 0.2) # better parameters示例源碼
需要調整幾個參數……過度擬合的風險
分割
-
基于_直方圖_的分割(沒有空間信息)
>>> n = 10>>> l = 256>>> im = np.zeros((l, l))>>> np.random.seed(1)>>> points = l*np.random.random((2, n**2))>>> im[(points[0]).astype(np.int), (points[1]).astype(np.int)] = 1>>> im = ndimage.gaussian_filter(im, sigma=l/(4.*n))>>> mask = (im > im.mean()).astype(np.float)>>> mask += 0.1 * im>>> img = mask + 0.2*np.random.randn(*mask.shape)>>> hist, bin_edges = np.histogram(img, bins=60)>>> bin_centers = 0.5*(bin_edges[:-1] + bin_edges[1:])>>> binary_img = img > 0.5
總結
以上是生活随笔為你收集整理的SciPy和Numpy处理能力的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 今日校园如何自动签到
- 下一篇: PythonGIS可视化—Matplot