Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
9f697510
Commit
9f697510
authored
Sep 22, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5320 from berak:lda_fix
parents
4bb4c92f
2f7c9266
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
core.hpp
modules/core/include/opencv2/core.hpp
+5
-5
lda.cpp
modules/core/src/lda.cpp
+6
-6
No files found.
modules/core/include/opencv2/core.hpp
View file @
9f697510
...
@@ -2381,8 +2381,7 @@ class CV_EXPORTS LDA
...
@@ -2381,8 +2381,7 @@ class CV_EXPORTS LDA
{
{
public
:
public
:
/** @brief constructor
/** @brief constructor
Initializes a LDA with num_components (default 0) and specifies how
Initializes a LDA with num_components (default 0).
samples are aligned (default dataAsRow=true).
*/
*/
explicit
LDA
(
int
num_components
=
0
);
explicit
LDA
(
int
num_components
=
0
);
...
@@ -2413,15 +2412,17 @@ public:
...
@@ -2413,15 +2412,17 @@ public:
*/
*/
~
LDA
();
~
LDA
();
/** Compute the discriminants for data in src and labels.
/** Compute the discriminants for data in src
(row aligned)
and labels.
*/
*/
void
compute
(
InputArrayOfArrays
src
,
InputArray
labels
);
void
compute
(
InputArrayOfArrays
src
,
InputArray
labels
);
/** Projects samples into the LDA subspace.
/** Projects samples into the LDA subspace.
src may be one or more row aligned samples.
*/
*/
Mat
project
(
InputArray
src
);
Mat
project
(
InputArray
src
);
/** Reconstructs projections from the LDA subspace.
/** Reconstructs projections from the LDA subspace.
src may be one or more row aligned projections.
*/
*/
Mat
reconstruct
(
InputArray
src
);
Mat
reconstruct
(
InputArray
src
);
...
@@ -2437,11 +2438,10 @@ public:
...
@@ -2437,11 +2438,10 @@ public:
static
Mat
subspaceReconstruct
(
InputArray
W
,
InputArray
mean
,
InputArray
src
);
static
Mat
subspaceReconstruct
(
InputArray
W
,
InputArray
mean
,
InputArray
src
);
protected
:
protected
:
bool
_dataAsRow
;
bool
_dataAsRow
;
// unused, but needed for 3.0 ABI compatibility.
int
_num_components
;
int
_num_components
;
Mat
_eigenvectors
;
Mat
_eigenvectors
;
Mat
_eigenvalues
;
Mat
_eigenvalues
;
void
lda
(
InputArrayOfArrays
src
,
InputArray
labels
);
void
lda
(
InputArrayOfArrays
src
,
InputArray
labels
);
};
};
...
...
modules/core/src/lda.cpp
View file @
9f697510
...
@@ -937,9 +937,9 @@ public:
...
@@ -937,9 +937,9 @@ public:
// Linear Discriminant Analysis implementation
// Linear Discriminant Analysis implementation
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
LDA
::
LDA
(
int
num_components
)
:
_num_components
(
num_components
)
{
}
LDA
::
LDA
(
int
num_components
)
:
_
dataAsRow
(
true
),
_
num_components
(
num_components
)
{
}
LDA
::
LDA
(
InputArrayOfArrays
src
,
InputArray
labels
,
int
num_components
)
:
_num_components
(
num_components
)
LDA
::
LDA
(
InputArrayOfArrays
src
,
InputArray
labels
,
int
num_components
)
:
_
dataAsRow
(
true
),
_
num_components
(
num_components
)
{
{
this
->
compute
(
src
,
labels
);
//! compute eigenvectors and eigenvalues
this
->
compute
(
src
,
labels
);
//! compute eigenvectors and eigenvalues
}
}
...
@@ -1106,14 +1106,14 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
...
@@ -1106,14 +1106,14 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
}
}
}
}
// Projects samples into the LDA subspace.
// Projects
one or more row aligned
samples into the LDA subspace.
Mat
LDA
::
project
(
InputArray
src
)
{
Mat
LDA
::
project
(
InputArray
src
)
{
return
subspaceProject
(
_eigenvectors
,
Mat
(),
_dataAsRow
?
src
:
src
.
getMat
().
t
()
);
return
subspaceProject
(
_eigenvectors
,
Mat
(),
src
);
}
}
// Reconstructs projections from the LDA subspace.
// Reconstructs projections from the LDA subspace
from one or more row aligned samples
.
Mat
LDA
::
reconstruct
(
InputArray
src
)
{
Mat
LDA
::
reconstruct
(
InputArray
src
)
{
return
subspaceReconstruct
(
_eigenvectors
,
Mat
(),
_dataAsRow
?
src
:
src
.
getMat
().
t
()
);
return
subspaceReconstruct
(
_eigenvectors
,
Mat
(),
src
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment