libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNFeatureSet.cpp
Go to the documentation of this file.
1 /* Copyright 2007-2016 Yann LEYDIER, INSA-Lyon, ENS-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNFeatureVector.cpp
19  * \author Yann LEYDIER
20  */
21 
22 #include <CRNi18n.h>
25 #include <CRNException.h>
26 #include <CRNBlock.h>
27 #include <CRNData/CRNDataFactory.h>
28 
29 using namespace crn;
30 
31 /*****************************************************************************/
39 {
40  auto fv = std::make_shared<Vector>();
41  for (size_t tmp = 0; tmp < Size(); tmp++)
42  fv->PushBack(std::static_pointer_cast<FeatureExtractor>(At(tmp))->Extract(b));
43  return fv;
44 }
45 
46 /*****************************************************************************/
55 {
56  auto fv = std::make_shared<Vector>();
57  for (size_t tmp = 0; tmp < Size(); tmp++)
58  fv->PushBack(std::static_pointer_cast<FeatureExtractor>(At(tmp))->ExtractWithMask(b, mask));
59  return fv;
60 }
61 
64 CRN_END_CLASS_CONSTRUCTOR(FeatureSet)
65 
Abstract class for images.
Definition: CRNImage.h:141
SVector ExtractWithMask(Block &b, ImageIntGray &mask)
Extracts all the features of the set from a block.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Definition: CRNObject.h:198
A block.
Definition: CRNBlock.h:52
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
SVector Extract(Block &b)
Extracts all the features of the set from a block.
Feature vector class.
Definition: CRNFeatureSet.h:39
SObject & At(size_t i)
Returns an object from index (unsafe)
Definition: CRNVector.h:65
size_t Size() const noexcept
Returns the number of data objects in the vector.
Definition: CRNVector.h:56
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Definition: CRNObject.h:185