"OpenCV-Python Tutorials" and mahotas

In relation to the translation about "OpenCV-Python Tutorials", this time I compared it with mahotas.

** What is Mahotas **

There are several libraries that use Python for image recognition, but there is also a library called mahotas. This also uses the data format of numpy. For libraries that perform image recognition with Python,

--Python binding to the development result in C ++ (OpenCV-Python) --Those that are accelerated using the Cython language based on the framework of numpy and Python (scikit-image) --Developing in C ++ while focusing on being a library for Python

there is. mahotas is developed in C ++, devoting itself to being a library for Python.

mahotas Why did you not simply contribute to scipy.ndimage or scikits.image? It explains why mahotas exists as a library different from scipy and scikit-image.

You can get the latest information about all the functions implemented in mahotas by launching [Python (x, y)] [Documentation] [Python documentation server] and accessing mahotas from site-packages.

http://mahotas.readthedocs.org/en/latest/index.html


###** Introduction to OpenCV **

Introduction to OpenCV-Python Tutorial

Intro_1 Let's get started with OpenCV-Python

Install OpenCV-Python on Windows Install_1 Make OpenCV available on windows.

Install OpenCV-Python on Fedora

Install_2 Make OpenCV available on Fedora.

If you are using Python (x, y) on Windows, first >>> import mahotas Please try. If there are no errors, you have already confirmed that mahotas is installed as a standard Python (x, y) plugin. If you get an error, you can get a compiled python module [Christoph Gohlke's site] It's a good idea to install from (http://www.lfd.uci.edu/~gohlke/pythonlibs/). I don't recommend compiling from source code in Visual Studio (Note 1) How to install Mahotas is shown on the Mahotas site as follows:

mahotas How To Install Mahotas


###** GUI features in OpenCV ** Let's start image manipulation gui_1画像を読み込むこと、表示すること、保存することを学びます。

Let's start video operation gui_2 動画の再生、カメラからの動画のキャプチャと動画としての保存を学びましょう。

OpenCV drawing functions gui_5 直線、矩形、楕円、円などをOpenCVを使って描画することを学びます。

Use mouse as paint brush gui_3 マウスを使って塗りつぶし

Use Trackbar as a color palette gui_4 パラメータを制御するためのtrackbarを作る


###** Core operation ** Basic operations on images

core_1 You will learn how to read and edit pixel values, operate images in the ROI (region of interest), and other basic operations.

"Practical machine learning system" Chapter 10 Computer vision pattern recognition Loading images using mahotas is introduced. Again, the data format after reading is numpy.array. The function name is also imread (). Since mahotas.imread (name) is read in RGB order, it is compatible when displayed by imshow () of matplotlib. (Note 2)

python


#!/usr/bin/python
# -*- coding: utf-8 -*-
import mahotas as mh
import pylab as plt

img=mh.imread("img_0000.png ")

plt.figure(1)
plt.imshow(img)
plt.show()

Arithmetic operations on images

core_2 Performs arithmetic operations on the image.

[Execution performance measurement and improvement method] (http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_core/py_optimization/py_optimization.html#optimization-techniques)

Core_4 It's important to get the answer. But getting the answer the fastest is even more important. Check the speed of your code, learn to optimize your code and more.

Mathematical methods in OpenCV core_5 PCA(Principalcomponentsanalysis 主成分分析)、SVD(singularvaluedecomposition 特異値分解)などのOpenCVで提供されている数学的手法のいくつかを学びます。


###** Image processing with OpenCV **

Change color space imgproc_1 異なる色空間で画像を変換する方法を学びましょう。そして動画で色つきの物体を追跡させてみましょう。

mahotas Color Space Conversions

Is there a conversion to sepia that is characteristic of mahotas color space conversion? Since the conversion of the color space of OpenCV is substantial, it is better to use it as a supplement.

lenas = mh.colors.rgb2sepia(lena)

Geometric transformation of images imgproc_gt 回転、変形などのさまざまな幾何変換を施してみましょう。

Image Threshold Processing imgproc_2 画像をグローバルしきい値、適応的閾値処理 、大津の2値化などで2値化画像に変換してみましょう。

mahotas also includes the binarization of Otsu. Another binarization method Riddler-Calvard method is also implemented.

Image Smoothing blurring.png 画像をぼかしたり、あつらえたカーネルを用いた画像にフィルタすることを学びます。

Morphological Transformation

Imgproc_12 Mol of contraction, expansion, Opening, Closing, etc. Learn about phology transformations.

Expansion and contraction are included in OpenCV, but conditional expansion and contraction are not included in OpenCV and mahotas It is included in, and it seems that it is worth using it well.

mahotas Dilation & Erosion

mahotas Conditional morphological erosion.

mahotas Conditional dilation

Image Gradients

Gradient.png Find image gradients, edges, etc. Let's do it.

Canny Edge Detection

imgproc_8 Let's find the edge using Canny edge detection.

mahotas Sobel edge detection

mahotas has a Difference of Gaussian. Compute edges using the Difference of Gaussian (DoG) operator. This differential operation is included in the procedure for calculating SIFT features. OpenCV does not have a direct Difference of Gaussian. An example of its implementation on stackoverflowを見つけて利用してみることができます。

Image Pyramid imgproc_14 画像ピラミッドとそれを画像混合に使う方法を学びます。

####** Contour processing with OpenCV **

Outline: Let's get started

contour_1 Find the outline and draw

Outline Features

Contour_2 Learn about finding various contour features, areas, perimeters, circumscribing rectangles, etc.

OpenCV is arguably the most complete library for image processing and image recognition, but binding in Python does not necessarily mean that all of its features are available. Labeling, for example, is one such feature. Libraries such as mahotas can make up for the missing features in the current OpenCV-Python framework (cv2) (Note 3).

Labeling Images

Contour Properties Contour_3 Learn to find various contour characteristics, solidity, average strength and more.

Outline: Other Functions

contour_4 Learn to find convexity defects, point Polygon Tests, and match with different shapes.

mahotas Convex hull convex hull

Contour Hierarchy

contour_5 Learn about the hierarchy of contours.

Histogram in OpenCV histogram.png OpenCVにあるヒストグラムの全て。

OpenCV Histogram in OpenCV

Histograms-1: Find, plot and analyze! !! !!

Hist_1 Find the histogram and draw it.

Histograms-2: Histogram flattening

Hist_2 Learn to flatten the histogram to get a good contrast image.

Histograms --3: Two-dimensional Histogram

Hist_3 Learn to find and plot a 2D histogram.

Histogram-4: Histogram Backprojection

Hist_4 Learn to back-project a histogram on an object colored by region.

Image conversion with OpenCV imgproc_7 フーリエ変換、コサイン変換などOpenCVにある様々な画像変換に出会ってみましょう。

Template Matching imgproc_9 テンプレートマッチングを用いて画像中から物体を探してみましょう。

mahotas Match template to image

Hough Transform imgproc_10 画像の中から線を検出してみましょう。

Hough Transform imgproc_11 画像の中から円を検出してみましょう。

Image segmentation based on the Watershed algorithm Imgproc_13 Let's divide the image area using the Watershed algorithm.

mahotas [Seeded watershed in n-dimensions] (http://mahotas.readthedocs.org/en/latest/api.html?highlight=watershed#mahotas.cwatershed)

Interactive foreground extraction using GrabCut algorithm

imgproc_15 Let's extract the foreground with the GrabCut algorithm.


###** Feature detection and feature description **

Understand features

F2d_1 What are the main features of the image? How useful are these features found?

Harris Corner Detection f2d_2 ええ、コーナーはよい特徴? でもどうやって見つけますか?

[Shi-Tomasi Corner Detector and Good Features to Track](http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_shi_tomasi/py_shi_tomasi.html#shi- tomasi) f2d_3 Let's take a look at the details of Shi-Tomasi corner detection.

Introduction to SIFT (Scale-Invariant Feature Transform) Features

F2d_4 Harris corner detectors are not good enough when the scale of the image changes. Lowe has developed a breakthrough method to find features that do not affect scale. It is called SIFT features.

Introduction to SURF (Speeded-Up Robust Features) Features

F2d_5 SIFT features are certainly good features. But it's not fast enough. Therefore, a high-speed version called SURF features was created.

mahotas also has SURF. Speeded-Up Robust Features

FAST algorithm for corner detection f2d_06 上に示した特徴検出器は全てよいものです。しかし、SLAM(訳注:SimultaneousLocalizationandMapping、自己位置推定と環境地図作成を同時に行うこと)のようなリアルタイムの用途に使えるほど十分に速いとは言えません。そこでFASTアルゴリズムの登場です。これは本当に"FAST(速い)"です。

BRIEF Independent Elementary Features f2d_07 SIFT特徴量は、128個の浮動小数点からなる特徴記述子を用いています。そのような特徴量を数千個あつかうことを考えてごらんなさい。そのときたくさんのメモリーとマッチングのためにたくさんの時間を使 is. You can compress the features to make them faster, but you still have to calculate the features first. That's where BRIEF comes in, offering a shortcut to finding binary descriptors with less memory, faster matching, and higher recognition.

ORB (Oriented FAST and Rotated BRIEF) features f2d_08 SIFT特徴量とSURF特徴量はとてもよく動くのだけれども、あなたの用途の中で使うには毎年数ドル払わなければならないとしたらどうしますか? それらは特許が成立しているのです。その問題を解決するには、OpenCVの開発者はSIFT特徴量とSURF特徴量への新しい"FREE"な代替品、ORBを思いつきました。

Feature Matching f2d_09 特徴検出器と記述子についてたくさん理解しました。異なる記述子を対応付ける方法を学ぶときです。OpenCVはそのために2つの手法、Brute-Forceマッチング手法とFLANNに基づくマッチング手法です。

Feature matching and homography for finding objects f2d_10 いま特徴量マッチングについて知っているので、複雑な画像中の物体を見つけるためにcalib3dモジュールとともに混ぜ合わせてみましょう。

Mahotas contains Haralic features that can distinguish between smooth and patterned images.

SURF features are also included in mahotas. "10.4 Description by local features"]

mahotas Local Binary Patterns


###** Video analysis ** Meanshift and Camshift Tracking (http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_video/py_meanshift/py_meanshift.html#meanshift)

Vdo_1 We have already seen an example of color-based tracking. It's simple. Let's take a look at how the better algorithm, mean shift and its improved version, CamShift, find and track objects.

[Optical flow] (http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html#lucas-kanade) Vdo_2 Let's learn about the important concept, optical flow. It is related to video and has many uses.

Background Removal

Vdo_b In some applications, it is necessary to extract the foreground like object tracking. Background removal is a well-known technique that helps in those cases.


###** Camera calibration and 3D reconstruction **

Camera Calibration calib_1 利用しているカメラがどれだけ良いものか試してみましょう。それで撮影した画像に歪みが見られるでしょうか?もしあれば、どう補正しましょうか?

Posture estimation calib_2 A short session to help you create a little cool 3D effect with the calib module.

Epipolar Geometry calib_3 エピポーラ幾何とエピポーラ制約を理解しましょう。

Depth distance information from stereo image calib_4 2D画像群から奥行き情報を得ます。

###** Machine learning ** K-nearest neighbor method ML_KNN K最近傍法の使い方を学ぶとともに、K最近傍法を用いて手書きの数字認識について学びます。

Support Vector Machine (SVM) ML_SVM SVMの考え方を理解します

K-means clustering Kmeansicon.png A group of data using K-means clustering Learn to classify into clusters. Then you will learn to perform color quantization using the K-means method.


###Computational Photography Here you will learn about the various features of OpenCV related to Computational Photography, such as image denoising.

Image Noise Removal photo_1 Non-local Meansノイズ除去と呼ばれる画像からノイズを除去する良好な手法を見ていただきます。

Image Repair photo_2 たくさんの黒点とひっかきを生じた古い劣化した写真を持っていませんか?それを持ってきて、画像修復と呼ばれる方法でそれらを復元してみましょう。


###** Object detection ** Face detection using Haar cascade detector objdet_1 Haar カスケード検出器を用いた顔検出


###** OpenCV-Python binding ** Now let's learn how OpenCV-Python bindings are made.

How does the OpenCV-Python binding work? bind1 OpenCV-Pythonバインディングがどのように作られているのか学びましょう。

Note 1: In Visual Studio, it is necessary to have the same version of Visual Studio that you are using, and it is very troublesome to have the same version of Visual Studio that builds all the libraries you use. Note 2: In the case of cv2.imread (name), the order is BGR, so it is necessary to use cv2.cvtColor (img, cv2.COLOR_BGR2RGB). Note 3: How to implement OpenCV Python bindings in cv2 is as described in the OpenCV-Python tutorial. In that way, advanced Python and C ++ users will be able to implement functions for which bindings have not been implemented. And how wonderful it is to donate it to the OpenCV community.

Recommended Posts

"OpenCV-Python Tutorials" and mahotas
Must-see "OpenCV-Python Tutorials"
"OpenCV-Python Tutorials" and "Practical Machine Learning System"
OpenCV-Python & Scikit-image-Addition to "Must-see" OpenCV-Python Tutorials "2"