points_classifier.cpp 18.7 KB
Newer Older
wester committed
1 2 3 4
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui.hpp"
wester committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#ifdef HAVE_OPENCV_OCL
#define _OCL_KNN_ 1 // select whether using ocl::KNN method or not, default is using
#define _OCL_SVM_ 1 // select whether using ocl::svm method or not, default is using
#include "opencv2/ocl/ocl.hpp"
#endif

#include <stdio.h>

using namespace std;
using namespace cv;

const Scalar WHITE_COLOR = Scalar(255,255,255);
const string winName = "points";
const int testStep = 5;

Mat img, imgDst;
RNG rng;

vector<Point>  trainedPoints;
vector<int>    trainedPointsMarkers;
wester committed
25 26 27 28 29
vector<Scalar> classColors;

#define _NBC_ 0 // normal Bayessian classifier
#define _KNN_ 0 // k nearest neighbors classifier
#define _SVM_ 0 // support vectors machine
wester committed
30
#define _DT_  1 // decision tree
wester committed
31
#define _BT_  0 // ADA Boost
wester committed
32
#define _GBT_ 0 // gradient boosted trees
wester committed
33 34 35 36
#define _RF_  0 // random forest
#define _ERT_ 0 // extremely randomized trees
#define _ANN_ 0 // artificial neural networks
#define _EM_  0 // expectation-maximization
wester committed
37 38 39 40 41 42 43 44

static void on_mouse( int event, int x, int y, int /*flags*/, void* )
{
    if( img.empty() )
        return;

    int updateFlag = 0;

wester committed
45
    if( event == CV_EVENT_LBUTTONUP )
wester committed
46
    {
wester committed
47 48 49
        if( classColors.empty() )
            return;

wester committed
50
        trainedPoints.push_back( Point(x,y) );
wester committed
51
        trainedPointsMarkers.push_back( (int)(classColors.size()-1) );
wester committed
52 53
        updateFlag = true;
    }
wester committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    else if( event == CV_EVENT_RBUTTONUP )
    {
#if _BT_
        if( classColors.size() < 2 )
        {
#endif
            classColors.push_back( Scalar((uchar)rng(256), (uchar)rng(256), (uchar)rng(256)) );
            updateFlag = true;
#if _BT_
        }
        else
            cout << "New class can not be added, because CvBoost can only be used for 2-class classification" << endl;
#endif

    }
wester committed
69 70 71 72 73 74

    //draw
    if( updateFlag )
    {
        img = Scalar::all(0);

wester committed
75 76 77 78 79 80 81 82 83 84 85 86 87
        // put the text
        stringstream text;
        text << "current class " << classColors.size()-1;
        putText( img, text.str(), Point(10,25), FONT_HERSHEY_SIMPLEX, 0.8f, WHITE_COLOR, 2 );

        text.str("");
        text << "total classes " << classColors.size();
        putText( img, text.str(), Point(10,50), FONT_HERSHEY_SIMPLEX, 0.8f, WHITE_COLOR, 2 );

        text.str("");
        text << "total points " << trainedPoints.size();
        putText(img, text.str(), Point(10,75), FONT_HERSHEY_SIMPLEX, 0.8f, WHITE_COLOR, 2 );

wester committed
88 89
        // draw points
        for( size_t i = 0; i < trainedPoints.size(); i++ )
wester committed
90
            circle( img, trainedPoints[i], 5, classColors[trainedPointsMarkers[i]], -1 );
wester committed
91 92 93 94 95

        imshow( winName, img );
   }
}

wester committed
96
static void prepare_train_data( Mat& samples, Mat& classes )
wester committed
97
{
wester committed
98 99
    Mat( trainedPoints ).copyTo( samples );
    Mat( trainedPointsMarkers ).copyTo( classes );
wester committed
100

wester committed
101 102 103
    // reshape trainData and change its type
    samples = samples.reshape( 1, samples.rows );
    samples.convertTo( samples, CV_32FC1 );
wester committed
104 105
}

wester committed
106 107
#if _NBC_
static void find_decision_boundary_NBC()
wester committed
108
{
wester committed
109 110 111 112 113 114 115 116
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvNormalBayesClassifier normalBayesClassifier( trainSamples, trainClasses );

wester committed
117 118 119 120 121 122 123 124
    Mat testSample( 1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

wester committed
125 126
            int response = (int)normalBayesClassifier.predict( testSample );
            circle( imgDst, Point(x,y), 1, classColors[response] );
wester committed
127 128 129 130 131 132 133 134 135
        }
    }
}
#endif


#if _KNN_
static void find_decision_boundary_KNN( int K )
{
wester committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
#if defined HAVE_OPENCV_OCL && _OCL_KNN_
    cv::ocl::KNearestNeighbour knnClassifier;
    Mat temp, result;
    knnClassifier.train(trainSamples, trainClasses, temp, false, K);
    cv::ocl::oclMat testSample_ocl, reslut_ocl;
#else
    CvKNearest knnClassifier( trainSamples, trainClasses, Mat(), false, K );
#endif

    Mat testSample( 1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;
#if defined HAVE_OPENCV_OCL && _OCL_KNN_
            testSample_ocl.upload(testSample);
wester committed
160

wester committed
161 162 163 164 165 166 167 168 169 170 171 172
            knnClassifier.find_nearest(testSample_ocl, K, reslut_ocl);

            reslut_ocl.download(result);
            int response = saturate_cast<int>(result.at<float>(0));
            circle(imgDst, Point(x, y), 1, classColors[response]);
#else

            int response = (int)knnClassifier.find_nearest( testSample, K );
            circle( imgDst, Point(x,y), 1, classColors[response] );
#endif
        }
    }
wester committed
173 174 175 176
}
#endif

#if _SVM_
wester committed
177
static void find_decision_boundary_SVM( CvSVMParams params )
wester committed
178
{
wester committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
#if defined HAVE_OPENCV_OCL && _OCL_SVM_
    cv::ocl::CvSVM_OCL svmClassifier(trainSamples, trainClasses, Mat(), Mat(), params);
#else
    CvSVM svmClassifier( trainSamples, trainClasses, Mat(), Mat(), params );
#endif

    Mat testSample( 1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            int response = (int)svmClassifier.predict( testSample );
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }


    for( int i = 0; i < svmClassifier.get_support_vector_count(); i++ )
wester committed
206
    {
wester committed
207 208
        const float* supportVector = svmClassifier.get_support_vector(i);
        circle( imgDst, Point(saturate_cast<int>(supportVector[0]),saturate_cast<int>(supportVector[1])), 5, CV_RGB(255,255,255), -1 );
wester committed
209
    }
wester committed
210

wester committed
211 212 213 214 215 216
}
#endif

#if _DT_
static void find_decision_boundary_DT()
{
wester committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvDTree  dtree;

    Mat var_types( 1, trainSamples.cols + 1, CV_8UC1, Scalar(CV_VAR_ORDERED) );
    var_types.at<uchar>( trainSamples.cols ) = CV_VAR_CATEGORICAL;

    CvDTreeParams params;
    params.max_depth = 8;
    params.min_sample_count = 2;
    params.use_surrogates = false;
    params.cv_folds = 0; // the number of cross-validation folds
    params.use_1se_rule = false;
    params.truncate_pruned_tree = false;

    dtree.train( trainSamples, CV_ROW_SAMPLE, trainClasses,
                 Mat(), Mat(), var_types, Mat(), params );

    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            int response = (int)dtree.predict( testSample )->value;
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }
wester committed
251 252 253 254
}
#endif

#if _BT_
wester committed
255
void find_decision_boundary_BT()
wester committed
256
{
wester committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvBoost  boost;

    Mat var_types( 1, trainSamples.cols + 1, CV_8UC1, Scalar(CV_VAR_ORDERED) );
    var_types.at<uchar>( trainSamples.cols ) = CV_VAR_CATEGORICAL;

    CvBoostParams  params( CvBoost::DISCRETE, // boost_type
                           100, // weak_count
                           0.95, // weight_trim_rate
                           2, // max_depth
                           false, //use_surrogates
                           0 // priors
                         );

    boost.train( trainSamples, CV_ROW_SAMPLE, trainClasses, Mat(), Mat(), var_types, Mat(), params );

    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            int response = (int)boost.predict( testSample );
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }
wester committed
290 291 292 293 294
}

#endif

#if _GBT_
wester committed
295
void find_decision_boundary_GBT()
wester committed
296
{
wester committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvGBTrees gbtrees;

    Mat var_types( 1, trainSamples.cols + 1, CV_8UC1, Scalar(CV_VAR_ORDERED) );
    var_types.at<uchar>( trainSamples.cols ) = CV_VAR_CATEGORICAL;

    CvGBTreesParams  params( CvGBTrees::DEVIANCE_LOSS, // loss_function_type
                             100, // weak_count
                             0.1f, // shrinkage
                             1.0f, // subsample_portion
                             2, // max_depth
                             false // use_surrogates )
                           );

    gbtrees.train( trainSamples, CV_ROW_SAMPLE, trainClasses, Mat(), Mat(), var_types, Mat(), params );

    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;
wester committed
325

wester committed
326 327 328 329
            int response = (int)gbtrees.predict( testSample );
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }
wester committed
330
}
wester committed
331

wester committed
332 333 334
#endif

#if _RF_
wester committed
335
void find_decision_boundary_RF()
wester committed
336
{
wester committed
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvRTrees  rtrees;
    CvRTParams  params( 4, // max_depth,
                        2, // min_sample_count,
                        0.f, // regression_accuracy,
                        false, // use_surrogates,
                        16, // max_categories,
                        0, // priors,
                        false, // calc_var_importance,
                        1, // nactive_vars,
                        5, // max_num_of_trees_in_the_forest,
                        0, // forest_accuracy,
                        CV_TERMCRIT_ITER // termcrit_type
                       );

    rtrees.train( trainSamples, CV_ROW_SAMPLE, trainClasses, Mat(), Mat(), Mat(), Mat(), params );

    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            int response = (int)rtrees.predict( testSample );
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }
wester committed
371 372 373 374
}

#endif

wester committed
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
#if _ERT_
void find_decision_boundary_ERT()
{
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // learn classifier
    CvERTrees ertrees;

    Mat var_types( 1, trainSamples.cols + 1, CV_8UC1, Scalar(CV_VAR_ORDERED) );
    var_types.at<uchar>( trainSamples.cols ) = CV_VAR_CATEGORICAL;

    CvRTParams  params( 4, // max_depth,
                        2, // min_sample_count,
                        0.f, // regression_accuracy,
                        false, // use_surrogates,
                        16, // max_categories,
                        0, // priors,
                        false, // calc_var_importance,
                        1, // nactive_vars,
                        5, // max_num_of_trees_in_the_forest,
                        0, // forest_accuracy,
                        CV_TERMCRIT_ITER // termcrit_type
                       );

    ertrees.train( trainSamples, CV_ROW_SAMPLE, trainClasses, Mat(), Mat(), var_types, Mat(), params );

    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            int response = (int)ertrees.predict( testSample );
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
        }
    }
}
#endif

wester committed
419
#if _ANN_
wester committed
420
void find_decision_boundary_ANN( const Mat&  layer_sizes )
wester committed
421
{
wester committed
422 423 424 425 426 427 428 429
    img.copyTo( imgDst );

    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );

    // prerare trainClasses
    trainClasses.create( trainedPoints.size(), classColors.size(), CV_32FC1 );
    for( int i = 0; i <  trainClasses.rows; i++ )
wester committed
430
    {
wester committed
431 432 433 434 435 436 437
        for( int k = 0; k < trainClasses.cols; k++ )
        {
            if( k == trainedPointsMarkers[i] )
                trainClasses.at<float>(i,k) = 1;
            else
                trainClasses.at<float>(i,k) = 0;
        }
wester committed
438 439
    }

wester committed
440 441 442 443 444
    Mat weights( 1, trainedPoints.size(), CV_32FC1, Scalar::all(1) );

    // learn classifier
    CvANN_MLP  ann( layer_sizes, CvANN_MLP::SIGMOID_SYM, 1, 1 );
    ann.train( trainSamples, trainClasses, weights );
wester committed
445

wester committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
    Mat testSample( 1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

            Mat outputs( 1, classColors.size(), CV_32FC1, testSample.data );
            ann.predict( testSample, outputs );
            Point maxLoc;
            minMaxLoc( outputs, 0, 0, 0, &maxLoc );
            circle( imgDst, Point(x,y), 2, classColors[maxLoc.x], 1 );
        }
    }
wester committed
461 462 463 464
}
#endif

#if _EM_
wester committed
465
void find_decision_boundary_EM()
wester committed
466 467 468
{
    img.copyTo( imgDst );

wester committed
469 470
    Mat trainSamples, trainClasses;
    prepare_train_data( trainSamples, trainClasses );
wester committed
471

wester committed
472
    vector<cv::EM> em_models(classColors.size());
wester committed
473

wester committed
474 475 476 477
    CV_Assert((int)trainClasses.total() == trainSamples.rows);
    CV_Assert((int)trainClasses.type() == CV_32SC1);

    for(size_t modelIndex = 0; modelIndex < em_models.size(); modelIndex++)
wester committed
478 479
    {
        const int componentCount = 3;
wester committed
480
        em_models[modelIndex] = EM(componentCount, cv::EM::COV_MAT_DIAGONAL);
wester committed
481

wester committed
482 483
        Mat modelSamples;
        for(int sampleIndex = 0; sampleIndex < trainSamples.rows; sampleIndex++)
wester committed
484
        {
wester committed
485 486
            if(trainClasses.at<int>(sampleIndex) == (int)modelIndex)
                modelSamples.push_back(trainSamples.row(sampleIndex));
wester committed
487 488 489
        }

        // learn models
wester committed
490 491
        if(!modelSamples.empty())
            em_models[modelIndex].train(modelSamples);
wester committed
492 493 494 495 496 497 498 499 500 501 502 503
    }

    // classify coordinate plane points using the bayes classifier, i.e.
    // y(x) = arg max_i=1_modelsCount likelihoods_i(x)
    Mat testSample(1, 2, CV_32FC1 );
    for( int y = 0; y < img.rows; y += testStep )
    {
        for( int x = 0; x < img.cols; x += testStep )
        {
            testSample.at<float>(0) = (float)x;
            testSample.at<float>(1) = (float)y;

wester committed
504 505
            Mat logLikelihoods(1, em_models.size(), CV_64FC1, Scalar(-DBL_MAX));
            for(size_t modelIndex = 0; modelIndex < em_models.size(); modelIndex++)
wester committed
506
            {
wester committed
507 508
                if(em_models[modelIndex].isTrained())
                    logLikelihoods.at<double>(modelIndex) = em_models[modelIndex].predict(testSample)[0];
wester committed
509 510 511
            }
            Point maxLoc;
            minMaxLoc(logLikelihoods, 0, 0, 0, &maxLoc);
wester committed
512 513 514

            int response = maxLoc.x;
            circle( imgDst, Point(x,y), 2, classColors[response], 1 );
wester committed
515 516 517 518 519 520 521 522
        }
    }
}
#endif

int main()
{
    cout << "Use:" << endl
wester committed
523
         << "  right mouse button - to add new class;" << endl
wester committed
524 525 526 527 528 529 530 531 532
         << "  left mouse button - to add new point;" << endl
         << "  key 'r' - to run the ML model;" << endl
         << "  key 'i' - to init (clear) the data." << endl << endl;

    cv::namedWindow( "points", 1 );
    img.create( 480, 640, CV_8UC3 );
    imgDst.create( 480, 640, CV_8UC3 );

    imshow( "points", img );
wester committed
533
    cvSetMouseCallback( "points", on_mouse );
wester committed
534 535 536

    for(;;)
    {
a  
Kai Westerkamp committed
537
        uchar key = (uchar)waitKey();
wester committed
538 539 540 541 542 543 544

        if( key == 27 ) break;

        if( key == 'i' ) // init
        {
            img = Scalar::all(0);

wester committed
545
            classColors.clear();
wester committed
546 547 548 549 550 551 552 553 554 555
            trainedPoints.clear();
            trainedPointsMarkers.clear();

            imshow( winName, img );
        }

        if( key == 'r' ) // run
        {
#if _NBC_
            find_decision_boundary_NBC();
wester committed
556
            namedWindow( "NormalBayesClassifier", WINDOW_AUTOSIZE );
wester committed
557 558 559
            imshow( "NormalBayesClassifier", imgDst );
#endif
#if _KNN_
wester committed
560 561 562
            int K = 3;
            find_decision_boundary_KNN( K );
            namedWindow( "kNN", WINDOW_AUTOSIZE );
wester committed
563 564
            imshow( "kNN", imgDst );

wester committed
565 566 567
            K = 15;
            find_decision_boundary_KNN( K );
            namedWindow( "kNN2", WINDOW_AUTOSIZE );
wester committed
568 569 570 571 572
            imshow( "kNN2", imgDst );
#endif

#if _SVM_
            //(1)-(2)separable and not sets
wester committed
573 574 575 576 577 578 579 580 581 582 583 584 585
            CvSVMParams params;
            params.svm_type = CvSVM::C_SVC;
            params.kernel_type = CvSVM::POLY; //CvSVM::LINEAR;
            params.degree = 0.5;
            params.gamma = 1;
            params.coef0 = 1;
            params.C = 1;
            params.nu = 0.5;
            params.p = 0;
            params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 1000, 0.01);

            find_decision_boundary_SVM( params );
            namedWindow( "classificationSVM1", WINDOW_AUTOSIZE );
wester committed
586 587
            imshow( "classificationSVM1", imgDst );

wester committed
588 589 590
            params.C = 10;
            find_decision_boundary_SVM( params );
            namedWindow( "classificationSVM2", WINDOW_AUTOSIZE );
wester committed
591 592 593 594 595
            imshow( "classificationSVM2", imgDst );
#endif

#if _DT_
            find_decision_boundary_DT();
wester committed
596
            namedWindow( "DT", WINDOW_AUTOSIZE );
wester committed
597 598 599 600 601
            imshow( "DT", imgDst );
#endif

#if _BT_
            find_decision_boundary_BT();
wester committed
602
            namedWindow( "BT", WINDOW_AUTOSIZE );
wester committed
603 604 605 606 607
            imshow( "BT", imgDst);
#endif

#if _GBT_
            find_decision_boundary_GBT();
wester committed
608
            namedWindow( "GBT", WINDOW_AUTOSIZE );
wester committed
609 610 611 612 613
            imshow( "GBT", imgDst);
#endif

#if _RF_
            find_decision_boundary_RF();
wester committed
614
            namedWindow( "RF", WINDOW_AUTOSIZE );
wester committed
615 616 617
            imshow( "RF", imgDst);
#endif

wester committed
618 619 620 621 622 623
#if _ERT_
            find_decision_boundary_ERT();
            namedWindow( "ERT", WINDOW_AUTOSIZE );
            imshow( "ERT", imgDst);
#endif

wester committed
624 625 626 627
#if _ANN_
            Mat layer_sizes1( 1, 3, CV_32SC1 );
            layer_sizes1.at<int>(0) = 2;
            layer_sizes1.at<int>(1) = 5;
wester committed
628
            layer_sizes1.at<int>(2) = classColors.size();
wester committed
629
            find_decision_boundary_ANN( layer_sizes1 );
wester committed
630
            namedWindow( "ANN", WINDOW_AUTOSIZE );
wester committed
631 632 633 634 635
            imshow( "ANN", imgDst );
#endif

#if _EM_
            find_decision_boundary_EM();
wester committed
636
            namedWindow( "EM", WINDOW_AUTOSIZE );
wester committed
637 638 639 640 641
            imshow( "EM", imgDst );
#endif
        }
    }

wester committed
642
    return 1;
wester committed
643
}