-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHRSAlternative.cc
44 lines (35 loc) · 1.09 KB
/
HRSAlternative.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//========================================================================
// HRSAlternative.cc
//========================================================================
// Alternative HRS implementation.
#include <cstddef>
#include <iostream>
#include "IHandwritingRecSys.h"
#include "Image.h"
#include "Vector.h"
#include "HRSAlternative.h"
#include "ece2400-stdlib.h"
//'''' ASSIGNMENT TASK '''''''''''''''''''''''''''''''''''''''''''''''''''
// Implement HRSAlternative.
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// K Nearest Neighbors
// default constructor
HRSAlternative::HRSAlternative( unsigned int K )
{
m_k = K;
}
// training
void HRSAlternative::train( const Vector<Image>& vec )
{
if ( m_k >= vec.size() )
throw ece2400::OutOfRange("The vector is empty.");
m_vec = vec;
Vector<int> imgVec;
size_t imgRows = m_vec[0].get_nrows();
size_t imgCols = m_vec[0].get_ncols();
size_t imgSize = imgRows * imgCols;
for( size_t i = 0; i < imgSize; i++ )
imgVec.push_back( 0 );
Image tempImg( imgVec, imgCols, imgRows );
m_empty = tempImg;
}