Public メソッド
クラス テンプレート dp_matching< Value_type, Functor >

DPマッチングを行うためのクラス [詳細]

#include <dp_matching.h>

Public メソッド

 dp_matching (const mist::array< Value_type > &pattern_a, const mist::array< Value_type > &pattern_b, const double weight_0, const double weight_1, const double weight_2, const Functor func=__dp__::square_error< Value_type >())
 コンストラクタ
void weights (const double weight_0, const double weight_1, const double weight_2)
 重みを変化させて対応付けをやり直す
const mist::array< dp_pair > & path () const
 対応付けられたパスを返す
size_t length () const
 対応付けられたパスの長さを返す
distance_type distance () const
 対応付けられたパスを通る場合のパターン間の距離を返す

説明

template<typename Value_type, typename Functor = __dp__::square_error< Value_type >>
class dp_matching< Value_type, Functor >

DPマッチングを行うためのクラス

任意のサイズ,データ型の1次元データ同士の対応付け

@attention 要素間の距離を返す関数をstd::binary_functionから継承したファンクタの形式で与える必要がある.
@attention 算術型,mist::rgb< 算術型 >に対しては、デフォルトで2乗距離を返すファンクタを用意してある.

@param Value_type  … 入力のデータ型( double や mist::rgb< unsigned char > など )
@param Functor     … 要素間の距離を返すファンクタ( デフォルトは __dp__::square_error< Value_type > )

@code 使用例

// 対応付けたい2つのパターンを用意 char data0[ ] = { 'a', 'b', 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c' }; char data1[ ] = { 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'c', 'c', 'c' }; mist::array< char > pattern0( 10 ), pattern1( 10 ); for( size_t i = 0 ; i < pattern0.size( ) ; i ++ ) { pattern0[ i ] = data0[ i ]; pattern1[ i ] = data1[ i ]; }

// 対応付け mist::dp_matching< char > dm0( pattern0, pattern1, 1.0, 2.0, 1.0 );

// 結果の表示 std::cout << dm0.path( ) << std::endl; std::cout << dm0.distance( ) << std::endl;

// 重みを変更して再度対応付け dm0.weights( 1.0, 1.0, 1.0 );

// 結果の表示 std::cout << dm0.path( ) << std::endl; std::cout << dm0.distance( ) << std::endl;

// 距離関数を指定して対応付け mist::dp_matching< char, my_distance > dm1( pattern0, pattern1, 1.0, 2.0, 1.0, my_distance( ) );

// 結果の表示 std::cout << dm1.path( ) << std::endl; std::cout << dm1.distance( ) << std::endl;

ここで、my_distanceは例えば以下のように定義できる.

ファンクタの例
1 #include <functional>
struct my_distance : public std::binary_function< char, char, double >
{
int operator ( )( const char v0, const char v1 ) const
{
return std::abs( static_cast< double >( v0 ) - v1 );
}
};

コンストラクタとデストラクタ

template<typename Value_type , typename Functor = __dp__::square_error< Value_type >>
dp_matching< Value_type, Functor >::dp_matching ( const mist::array< Value_type > &  pattern_a,
const mist::array< Value_type > &  pattern_b,
const double  weight_0,
const double  weight_1,
const double  weight_2,
const Functor  func = __dp__::square_error< Value_type >( ) 
)
inline

コンストラクタ

引数
[in]pattern_a… 入力パターンA
[in]pattern_b… 入力パターンB
[in]weight_0… 横方向重み
[in]weight_1… 斜め方向重み
[in]weight_2… 縦方向重み
[in]func… 要素間の距離を返すファンクタ(デフォルト値:__dp__::square_error< Value_type >( ))

関数

template<typename Value_type , typename Functor = __dp__::square_error< Value_type >>
distance_type dp_matching< Value_type, Functor >::distance ( ) const
inline

対応付けられたパスを通る場合のパターン間の距離を返す

戻り値
パターン間の距離
template<typename Value_type , typename Functor = __dp__::square_error< Value_type >>
size_t dp_matching< Value_type, Functor >::length ( ) const
inline

対応付けられたパスの長さを返す

戻り値
パスの長さ

参照先 mist::array< T, Allocator >::size().

template<typename Value_type , typename Functor = __dp__::square_error< Value_type >>
const mist::array< dp_pair >& dp_matching< Value_type, Functor >::path ( ) const
inline

対応付けられたパスを返す

戻り値
対応付けられたパス
template<typename Value_type , typename Functor = __dp__::square_error< Value_type >>
void dp_matching< Value_type, Functor >::weights ( const double  weight_0,
const double  weight_1,
const double  weight_2 
)
inline

重みを変化させて対応付けをやり直す

引数
[in]weight_0… 横方向重み
[in]weight_1… 斜め方向重み
[in]weight_2… 縦方向重み

このクラスの説明は次のファイルから生成されました:

Generated on Wed Nov 12 2014 19:44:28 for MIST by doxygen 1.8.1.2