ラベル K-means Clustering の投稿を表示しています。 すべての投稿を表示
ラベル K-means Clustering の投稿を表示しています。 すべての投稿を表示

2014年8月6日水曜日

Coatesの方法 追記

先に考察したCoatesの方法について、クラスタリングの数 $K$ を変えた結果を示す。その他のパラメータは先と同じである。 テスト画像は100枚である。

1. MITforest/MITmountainの組


$K$ accuracy accuracy(Hellinger Kernel)
1000 81%(81/100) 86%(86/100)
1500 86%(86/100) 86%(86/100)
2000 69%(69/100) 88%(88/100)


2. industrial/CALsuburbの組


$K$ accuracy accuracy(Hellinger Kernel)
1000 88%(88/100) 97%(97/100)
1500 88%(88/100) 97%(97/100)
2000 97%(97/100) 98%(98/100)


3. MITmountain/MITopencountryの組


$K$ accuracy accuracy(Hellinger Kernel)
1000 75%(75/100) 83%(83/100)
1500 64%(64/100) 87%(87/100)
2000 87%(87/100) 81%(81/100)


4. 考察

  1. 最後の組の $K=2000$ の場合を除けば、Hellinger Kernelを使用したときの識別率は、それを使用しないときより低くなることはない。
  2. 最後の組の $K=2000$ の場合を除けば、Hellinger Kernelを使用したときの識別率は、$K$ が大きい程高くなる。
  3. ただし、Hellinger Kernelを使わない場合も考慮に入れると、$K$ の増加がそのまま識別率の向上につながるわけではないことが分る。
今回使用した識別器は以下の2種類である。
  1. 線形SVM
  2. Homogeneous Kernel Mapという手法により導入したHellinger Kernel

5. テスト画像の例


以下に各カテゴリのテスト画像の例を示す。

〜 MITforest 〜


〜 MITmountain 〜


〜 industrial 〜


〜 CALsuburb 〜


〜 MITopencountry 〜


2014年7月27日日曜日

Coates's Method

in Japanese

1. Introduction


 In recent years a considerable number of studies have been made on the deep learning. The study by A. Coates et al. [1] focused on the reason why the deep learning achieves high performance. I have implemented their algorithm and applied it to the dataset I have at hand. In this page, I will provide a detailed explanation on their algorithm and show my results.

2. Algorithm


 To realize the Coates's method, three datasets are needed:
  1. $S_{\rm unsupervised}$ : a dataset to construct the function which maps an image patch to a feature vector
  2. $S_{\rm training}$ : a dataset to train the Support Vector Machine (SVM)
  3. $S_{\rm test}$ : a dataset to test the SVM
In my study, $S_{\rm unsupervised}$ and $S_{\rm training}$ are the same. First I conduct the following procedures to the dataset $S_{\rm unsupervised}$.

〜 Random Extraction of Patches 〜

  1. Extract randomly $n$ patches of $w \times w$ pixels from an image.
  2. Arrange pixels in a row from the left-top pixel to the right-bottom one of the patch to make a $N$-dimensional vector $\vec{x}$, where $N=d\times w\times w$ and $d$ is the number of channels. $d=3$ if the patch is color and $d=1$ if it is gray. As in my study the color image is converted to the gray one, $d$ is always 1.
  3. If there are $m$ images, the number of $N$-dimensional vectors is $M(=n\times m)$ as \begin{equation} \vec{x}^{\;\mu}, \mu=1,\cdots,M \end{equation}

〜 Normalization and Whitening 〜

  1. For each vector $\vec{x}^{\;\mu}$, the average and the variance are calculated as \begin{eqnarray} \bar{x}^{\mu}&=&\frac{1}{N}\sum_{i=1}^{N}x_{i}^{\mu} \nonumber \\ \sigma_{\mu}^2 &=& \frac{1}{N}\sum_{i=1}^{N}\left(x_{i}^{\mu} - \bar{x}^{\mu}\right)^{2}. \nonumber \end{eqnarray} Using them, $\vec{x}^{\;\mu}$ is redefined by \begin{equation} x_{i}^{\mu} = \frac{x_{i}^{\mu} - \bar{x}^{\mu} }{ \sqrt{ \sigma_{\mu}^{2}+\epsilon_{\rm n} } }, \end{equation} where $\epsilon_{\rm n}$ is a small value to avoid divide-by-zero. This procedure corresponds to the brightness and contrast normalization of the local area.
  2. After normalizing $M$ vectors, they are whitened. Here is the detailed explanation on the whitening.

〜 Clustering 〜


 The $K$-means clustering is applied to $M$ $N$-dimensional vectors. I have fully explained the clustering in this page. $K$ centroids are obtained.
 The image shown below indicates 961 centroids when $K=1000$ and $w=6$. To draw the image, after the elements of each vector are scaled so that they stay within the range of [0,255], the vector is converted to a 6$\times$6 image.

〜 Mapping to Feature Vector 〜


 At this point, the following quantities are obtained:
  1. The whitening matrix, $M_{\rm W}$
  2. $K$ centroids, $\vec{c}_{\;k}, k=1,\cdots,K$.
Using them, the function which maps a patch to a feature vector is constructed. The procedures are as follows:
  1. Arrange pixels in a row from the left-top pixel to the right-bottom one of a path to make a $N$-dimensional vector $\vec{x}$.
  2. Normalize the vector $\vec{x}$.
  3. Whiten the normalized vector as $\vec{x}_{\rm W} = M_{\rm W}\;\vec{x}$
  4. Define the function $f_{k}(\vec{x}_{\rm W})$ as \begin{equation} f_{k}(\vec{x}_{\rm W})=\max{\left(0, \mu(z)-z_k\right)}, \nonumber \end{equation} where \begin{eqnarray} z_k&=&\|\vec{x}_{\rm W}-\vec{c}_{k} \| \nonumber \\ \mu(z)&=&\frac{1}{K}\sum_{k=1}^{K}z_k. \nonumber \end{eqnarray} $\mu(z)$ is the average distance between the vector $\vec{x}_{\rm W}$ and the $K$ centroids. The function $f_{k}$ outputs 0 if the distance $z_{k}$ between $\vec{x}_{\rm W}$ and the $k$-th centroid $\vec{c}_{k}$ is greater than the average $\mu(z)$ and outputs the finite value $\mu(z) - z_{k}$ if $z_{k}$ is less than $\mu(z)$. In other words in the context of the centroid images shown above, the function $f_{k}$ represents a degree of contribution of $K$ centroids to a patch. The function $f_{k}$ maps a $N$-dimensional vector to a $K$-dimensional vector. This is the feature vector.

Next the following procedures are conducted to the dataset $S_{\rm training}$.

〜 Extraction of Feature Vectors From Training Images〜

  1. Suppose that one image is given. The patches of $w\times w$ pixels are sequentially extracted from the image with the step size $s$ (stride).
  2. Convert a patch to a $K$-dimensional vector.
  3. The entire region which consists of all extracted patches is split into four equal-sized quadrants. Compute the average of the feature vectors in each quadrant. This procedure corresponds to the pooling in the deep learning. It not only decreases the location-dependency but also reduces the dimensionality of the feature vector.
  4. The four $K$-dimensional vectors yields a $4K$-dimensional vector. This is the feature vector made from one image. It is used for the classification by the SVM.
  5. If there are $D$ images, the number of $4K$-dimensional feature vectors is $D$.
  6. Train the SVM by using them.
 In the Coates's method, both the patch extraction and the pooling are executed only once. Moreover, the mapping function $f_{k}$ is computed using the unsupervised learning algorithm ($K$-means clustering). This is why the title of their paper is "Single-Layer Networks in Unsupervised Feature Learning."

Finally, the following procedures are conducted to the dataset $S_{\rm test}$.

〜 Classification of Test Dataset 〜

  1. Convert a given image to a $4K$-dimensional feature vector.
  2. Classify it by the SVM.

3. Implementation


I have implemented the algorithm in C++ and used the following libraries:
  1. opencv2: in order to implement procedures related to the image processing and the $K$-means clustering.
  2. boost::numeric::ublas: in order to implement the whitening computation.
  3. liblinear: in order to train SVM and classify images.
I have also used the python as a glue that binds procedures together.

4. Image Dataset


 I have used the dataset called LSP15. It can be downloaded by clicking the title "scene category dataset" on this site. It has indoor and outdoor images that are classified into 15 categories. The number of images in each category is about 200 to 300, and image size is approximately 300$\times$300 pixels.
 I have selected two categories and constructed four datasets $S_{\rm training}^{A/B}$ and $S_{\rm test}^{A/B}$.

category training test label
A 1-150 ($S_{\rm training}^{A}$) 151-200 ($S_{\rm test}^{A}$) -1
B 1-150 ($S_{\rm training}^{B}$) 151-200 ($S_{\rm test}^{B}$) +1

The name of the image has an integer value like "image_0001.jpg." The integer value in the above table except for labels indicates the image name. The number of the training images and the test images are 150 and 50, respectively. The dataset used for making the feature mapping function $f_{k}$ is $S_{\rm unsupervised}=S_{\rm training}^{A} + S_{\rm training}^{B}$ which contains 300 images. Since the dataset includes 3-channel images (color images), they are converted to the gray images.

5. Parameters


 I have chosen the following parameters:

$n$ $w$ $s$ $K$ $\epsilon_{\rm n}$ $\epsilon_{\rm w}$
50 6 1 1000 10 0.1

$\epsilon_{\rm w}$ is a small value to avoid divide-by-zero in the whitening matrix $M_{\rm W}$ defined by \begin{equation} M_{\rm W}=R\;\left(\Lambda+\epsilon_{\rm w}I\right)^{-1/2}\;R^{T}, \label{eq7} \end{equation} where $I$ is the identity matrix. I have already described the detailed explanation on the whitening here.

6. Accuracy


 The results are shown below:

category A category B accuracy accuracy(Hellinger Kernel)
bedroom CALsuburb 99%(99/100) 97%(97/100)
livingroom industrial 94%(94/100) 97%(97/100)
MITforest MITmountain 81%(81/100) 86%(86/100)
industrial CALsuburb 88%(88/100) 97%(97/100)

 The Hellinger Kernel is able to be introduced by using the linear SVM after computing the square root of the element of the feature vector (Homogeneous Kernel Map).

7. Discussion

  1. The accuracies are high in despite of the linear SVM.
  2. The Hellinger Kernel is effective except for the pair of bedroom and CALsuburb.
  3. The accuracy of the pair of MITforest and MITmountain is low compared with other pairs. If you see the sample images as shown below, it turns out that the images of the two categories are similar.
  4. The high performance is achieved without the commonly-used local feature algorithms, e.g. SIFT, SURF, BRIST, and so on. Will the study on them fade out?
 Two test images from each category are shown below:

〜 bedroom 〜


〜 livingroom 〜


〜 MITforest 〜


〜 industrial 〜


〜 MITmountain 〜


〜 CALsuburb 〜


8. References


  • An Analysis of Single-Layer Networks in Unsupervised Feature Learning, A. Coates, H. Lee, and A. Y. Ng, 2010
  • 2014年7月23日水曜日

    Coatesの方法

    in English

    1. はじめに


     近年、Deep Learning の研究が盛んである。その中にはその高精度の原因を解明しようする研究もある。そのひとつが A.Coates らの "An Analysis of Single-Layer Networks in Unsupervised Feature Learning" である。今回これを実装し手元にある画像に適用してみたのでまとめます。

    2. アルゴリズム


     このアルゴリズムを検証するには、3つの画像セットが必要である。
    1. 特徴ベクトルを生成する関数を作るための画像セット($S_{\rm unsupervised}$)
    2. 訓練用画像セット($S_{\rm training}$)
    3. テスト用画像セット($S_{\rm test}$)
    今回は、1と2を同じ画像セットとした。以下、アルゴリズムの詳細を順に示す。

    最初に、$S_{\rm unsupervised}$ を使用して以下を行う。

    〜 パッチの切り出し 〜

    1. 1枚の画像からサイズ $w \times w$ のパッチをランダムに $n$ 枚切り出す。
    2. 1つのパッチの画素を左上から右下に向かって1列に並べ、$N$ 次元のベクトル $\vec{x}$ を作る。ここで $N=d\times w \times w$、$d$ は画像のチャンネル数である。カラー画像なら3、グレイ画像なら1である。
    3. 複数枚の画像について同じことを繰り返す。画像が $m$ 枚あれば $N$ 次元ベクトルは $M(=n\times m)$ 個作られる( $\vec{x}^{\;\mu}, \mu=1,\cdots,M$ )。

    〜 正規化と白色化 〜

    1. 現在、$M$ 個の$N$ 次元ベクトルがある。個々のベクトルに対し、その成分の平均値と分散を計算し、正規化を行う。 \begin{eqnarray} \bar{x}^{\mu}&=&\frac{1}{N}\sum_{i=1}^{N}x_{i}^{\mu} \nonumber \\ \sigma_{\mu}^2 &=& \frac{1}{N}\sum_{i=1}^{N}\left(x_{i}^{\mu} - \bar{x}^{\mu}\right)^{2} \nonumber \end{eqnarray} これらを使って、改めて $\vec{x}^{\;\mu}$ を定義し直す。 \begin{equation} x_{i}^{\mu} = \frac{x_{i}^{\mu} - \bar{x}^{\mu} }{ \sqrt{ \sigma_{\mu}^{2}+\epsilon_{\rm n} } } \end{equation} ここで、$\epsilon_{\rm n}$ は0割りを防ぐ微小量である。この作業は、局所領域(パッチ)内での明るさとコントラストの正規化に相当する。
    2. 正規化された $M$ 個のベクトルを使って、白色化を行う。白色化の手順はここにまとめてある。

    〜 クラスタリング 〜


     $M$ 個の $N$ 次元ベクトルに対し、$K$-meansクラスタリングを行う。クラスタリングの手順はここにまとめてある。$K$ 個の重心が求まる。
     下の画像は $K=1000$ としたときの961個の重心ベクトル($N=36$次元ベクトル)を画像化したものである(成分の最小値を0に最大値を255に置き換え6$\times$6の画像に変換した)。

    〜 特徴ベクトルの作成 〜


     ここまでの手順で以下のものが取得できた。
    1. 白色化行列 $M_{\rm W}$
    2. $K$ 個の重心座標 $\vec{c}_{\;k}, k=1,\cdots,K$
    これらを使って、画像から取り出した1つのパッチから1つの特徴ベクトルを生成する関数を組み立てる。その手順は以下の通りである。
    1. パッチの画素を左上から右下に向かって1列に並べ、$N$ 次元のベクトル $\vec{x}$ を作成する。
    2. $\vec{x}$ を正規化する。
    3. 正規化した $\vec{x}$ に白色化行列 $M_{\rm W}$ をかけて白色化する。$\vec{x}_{\rm W} = M_{\rm W}\;\vec{x}$
    4. 関数 $f_{k}(\vec{x}_{\rm W})$ を次式で定義する。 \begin{equation} f_{k}(\vec{x}_{\rm W})=\max{\left(0, \mu(z)-z_k\right)} \nonumber \end{equation} ここで、 \begin{eqnarray} z_k&=&\|\vec{x}_{\rm W}-\vec{c}_{\;k} \| \nonumber \\ \mu(z)&=&\frac{1}{K}\sum_{k=1}^{K}z_k \nonumber \end{eqnarray} である。つまり、ある点 $\vec{x}_{\rm W}$ に注目したとき、この点と $K$ 個の重心との平均距離を算出する。 そして、平均距離より近い重心のインデックスには有限値を、遠い重心のインデックスには0を割り振る。 上の重心画像を使ってもう少し言い換えると、個々のパッチに対する各重心画像の寄与の度合いを表していることになる。 関数 $f_{k}$ により $N$ 次元ベクトルは、$K$ 次元ベクトルに変換される。これが特徴ベクトルである。

    次に、$S_{\rm training}$ に対し以下を行う。

    〜 訓練画像からの特徴ベクトルの抽出〜

    1. 1枚の訓練画像を考える。サイズ $w\times w$ のパッチを切り出す。その際、次のパッチとの距離(ストライド)を $s$ とする。左上から右下に向かって規則正しくパッチを取り出す。
    2. 各パッチから $K$ 次元の特徴ベクトルを算出する。
    3. 取り出したパッチが作る全領域を4等分し、各矩形に属する特徴ベクトルの平均ベクトルを計算する。この作業は、Deep LearningにおけるPoolingに相当する。識別対象の位置依存性を減らす手続きでもある。
    4. 4つの $K$ 次元ベクトルを並べた4 $K$ 次元ベクトルを、画像1枚に対する特徴ベクトルとする。
    5. 全ての訓練画像に対し同じことを繰り返す。訓練画像が $D$ 枚あれば、$D$ 個の4 $K$ 次元ベクトルが作られる。
    6. これらを使って、SVMで訓練する。
     上の図を見れば明らかであるが、本手法はパッチの走査とPoolingがそれぞれ一度だけ行われる。また、パッチを特徴ベクトルへ変換する関数 $f_k$ は教師なし学習($K$-meansクラスタリング)により得られる。よって、Single-Layer Networks in Unsupervised Feature Learning なのである。

    最後に、$S_{\rm test}$ に対し以下を行う。

    〜 テスト画像の評価 〜

    1. 上と全く同じ手順で1枚の画像を4 $K$ 次元の特徴ベクトルに変換する。
    2. SVMで識別する。

    3. 実装


    実装言語はC++、使用したライブラリは以下の通りである。
    1. opencv2: 画像周りや $K$-meansクラスタリングなど。
    2. boost::numeric::ublas: 白色化の計算など。
    3. liblinear: 線形SVMを使った訓練とテスト。
    また、アルゴリズムの各手順をつなぎ合わせる際、pythonを使用した。

    4. 画像セット


     使用した画像セットはLSP15と呼ばれているものである。ここの scene category dataset という項目をクリックするとダウンロードできる。15個のカテゴリに分類された室内・室外画像である。各カテゴリには、縦横200から300ピクセル程度の画像が200から300枚ほど含まれている。
     今回の検証では、15個のカテゴリから適当に2つを選択し、画像セット $S_{\rm training}^{A/B}$、$S_{\rm test}^{A/B}$ を構成した。

    category training test label
    A 1-150 ($S_{\rm training}^{A}$) 151-200 ($S_{\rm test}^{A}$) -1
    B 1-150 ($S_{\rm training}^{B}$) 151-200 ($S_{\rm test}^{B}$) +1

    ダウンロードした画像にはimage_0001.jpgのような番号を含む名前が付けられている。上の表の番号はこれを表す。 訓練画像は各カテゴリから150枚、テスト画像は50枚を選択した。 また、関数 $f_{k}$ を作るための画像セット $S_{\rm unsupervised}$は、$S_{\rm training}^{A} + S_{\rm training}^{B}$ とした。総数は300枚である。画像セットにはカラー画像も混ざっているが全てグレー画像に変換して検証を行った。

    5. パラメータ


     各種パラメータの値は以下の通りである。

    $n$ $w$ $s$ $K$ $\epsilon_{\rm n}$ $\epsilon_{\rm w}$
    50 6 1 1000 10 0.1

    ここで、$\epsilon_{\rm w}$ は白色化行列 $M_{\rm W}$ の0割りを防ぐ微小量である。 \begin{equation} M_{\rm W}=R\;\left(\Lambda+\epsilon_{\rm w}I\right)^{-1/2}\;R^{T} \label{eq7} \end{equation} ただし、$I$ は単位行列である。白色化行列の詳細はここにまとめてある。

    6. 識別率


     結果を以下に示す。accuracyは通常の線形SVMを、accuracy(Hellinger Kernel)はHellinger Kernelを使用したときの識別率である。

    category A category B accuracy accuracy(Hellinger Kernel)
    bedroom CALsuburb 99%(99/100) 97%(97/100)
    livingroom industrial 94%(94/100) 97%(97/100)
    MITforest MITmountain 81%(81/100) 86%(86/100)
    industrial CALsuburb 88%(88/100) 97%(97/100)

     Hellinger Kernelは、特徴ベクトルの各成分の平方根を計算したあと線形SVMを適用すれば実現できる(Homogeneous Kernel Map)。

    7. 考察

    1. 線形SVMであるが全般的に識別率は高い。
    2. 1つを除いて、Hellinger Kernelの効果は高い。
    3. MITforestとMITmountainの組の識別率が他と比べて低いが、下のサンプル画像を見れば納得できると思う。
    4. 特別な局所特徴アルゴリズムを使わなくても高い識別率を達成できている。局所特徴アルゴリズムの研究は廃れていくのだろうか?
    以下に各カテゴリのテスト画像の例を示す。

    〜 bedroom 〜


    〜 livingroom 〜


    〜 MITforest 〜


    〜 industrial 〜


    〜 MITmountain 〜


    〜 CALsuburb 〜


    2013年3月7日木曜日

    K-means Clustering

    in Japanese

    Introduction

    In this page, I will describe a brief explanation on the theory of the K-means clustering and implement a simple image segmentation by means of a function cv::kmeans the OpenCV provides to us.

    Theory

    Suppose we have a data set consisting of N points each of which is defined in the D-dimensional Euclidean space as
    .
    Our goal is to partition the data set into some number K of clusters, where the value of K is given.
    When we introduce a vector to represent a center of each cluster, an objective function we should minimize is defined as

    where, is a variable that equals 1 if the point belongs to the cluster k, otherwise 0.
    The procedures to minimize J are as follows:
    1. Initialize the cluster centers in some way.
    2. Minimize J with respect to the , keeping the fixed.
    3. Minimize J with respect to the , keeping the fixed.
    4. Repeat these optimizations until both of the and the converge.
    It's easy to realize the 2nd procedure. It's only necessary to choose which has the minimum distance to the point we now consider and set to 1.
    In order to consider the 3rd procedure, we set J's derivative with respect to to zero,

    It results in the following equation,

    The denominator in this expression is equal to the number of points assigned to the cluster k. Namely, indicates the mean of all of the data points assigned to the cluster k. On the basis of these discussion, the procedures to minimize J are rewritten as follows:
    1. Decide the initial centers of the clusters in some way.
    2. Assign points to the closest clusters.
    3. Calculate the mean of the points assigned to the cluster, and replace the center by the mean.
    4. Repeat the 2nd and the 3rd procedures until the centers of the clusters converge.
    A direct implementation of the 2nd procedure is to compute the distance between every center and every point and to find the minimum distance. As it is relatively slow, we have to introduce a data structure such as a tree.

    Practice in OpenCV

    A function to execute the K-means clustering is cv::kmeans. In the following program, the 3 dimensional space (RGB) is considered. A pixel on an image corresponds to a point in 3D space. The K-means clustering yields the K clusters each of which has a set of points with similar color.
    1. 3rd-11th lines : Display an input image. A variable image indicates a H x W matrix with 3 channels. H and W are the height and the width of the image, respectively.
    2. 13th-15th lines : The function cv::kmeans requires the matrix in which each row corresponds to a coordinate of a point. In this sample program, the coordinate of the point is (B,G,R). To meet the requirement, the matrix image must be modified by using a function reshape. After the modification, image translates into a T x 3 matrix with 1 channel (reshaped_image), where T=W * H.
    3. 18th-21th lines : As the function cv::kmeans also requires the matrix consisting of floating-point elements, reshaped_image must be converted to the floating-point matrix (reshaped_image32f) by applying a function convertTo.
    4. 23th-27th lines : After preparing two matrices for outputs (labels and centers) and creating an instance of cv::TermCriteria which represents conditions to quit the algorithm, we execute the function cv::kmeans. In this case, I chose the maximum number of iteration (100) as the condition to quit the algorithm. The final argument of the constructor of cv::TermCriteria is not used. The 6th argument of the function cv::kmeans is set to cv::KMEANS_RANDOM_CENTERS. This means that the initial centers of the clusters are randomly decided.
    5. 29th line : Display result. A function show_result is as follows:
    1. 3rd-7th lines : A variable labels indicates a T x 1 matrix. The each row of it has the value of the label. If cluster_number is 3, the value is either 0, 1, or 2. A variable centers is a cluster_number x 3 matrix. The each row of it has a coordinate of a center of a cluster. In this case, the coordinate corresponds to the vector specified in the RGB space.
    2. 9th line : Prepare a matrix rgb_image in which the final image is stored.
    3. 14th-16th lines : The matrix centers has floating-point values. These values are converted into std::uint8_t-type ones with the range [0,255]. Moreover, the number of channels is also translated into 3.
    4. 18th-23th lines:The label is replaced by the corresponding (B,G,R) to make the final image rgb_image.
    The results are as follows:
    cluster_number=2

    cluster_number=3
    cluster_number=5
    cluster_number=10
    original image

    Development Environment

    1. Mac OS X 10.8.2
    2. Processor:3.06 GHz Intel Core 2 Duo
    3. Memory:4GB
    4. Xcode4.6 with Apple LLVM 4.2(C++ Language Dialect → GNU++11, C++ Standard Library → libc++)
    5. boost-1.51.0 built by the Apple LLVM 4.1. See here
    6. opencv-2.4.3 built by the Apple LLVM 4.2. See here.

    Reference

    1. Pattern Recognition and Machine Learning, Christopher M. Bishop, Springer, p424-430
    2. OpenCV Document