Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miscmaths
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
miscmaths
Commits
bc83bde8
Commit
bc83bde8
authored
17 years ago
by
Mark Woolrich
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
7a097255
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
histogram.cc
+44
-0
44 additions, 0 deletions
histogram.cc
histogram.h
+21
-5
21 additions, 5 deletions
histogram.h
with
65 additions
and
5 deletions
histogram.cc
+
44
−
0
View file @
bc83bde8
...
...
@@ -9,6 +9,7 @@
#include
"miscmaths.h"
#include
"histogram.h"
#include
<strstream>
using
namespace
std
;
#ifndef NO_NAMESPACE
...
...
@@ -46,6 +47,49 @@ namespace MISCMATHS {
}
}
void
Histogram
::
smooth
()
{
Tracer
ts
(
"Histogram::smooth"
);
ColumnVector
newhist
=
histogram
;
// smooth in i direction
newhist
=
0
;
for
(
int
i
=
1
;
i
<=
bins
;
i
++
)
{
float
val
=
0.5
*
histogram
(
i
);
float
norm
=
0.5
;
if
(
i
>
1
)
{
val
+=
0.2283
*
(
histogram
(
i
-
1
));
norm
+=
0.2283
;
}
if
(
i
>
2
)
{
val
+=
0.0219
*
(
histogram
(
i
-
2
));
norm
+=
0.0219
;
}
if
(
i
<
bins
)
{
val
+=
0.2283
*
(
histogram
(
i
+
1
));
norm
+=
0.2283
;
}
if
(
i
<
bins
-
1
)
{
val
+=
0.0219
*
(
histogram
(
i
+
2
));
norm
+=
0.0219
;
}
val
/=
norm
;
newhist
(
i
)
=
val
;
}
histogram
=
newhist
;
}
int
Histogram
::
integrate
(
float
value1
,
float
value2
)
const
{
int
upperLimit
=
getBin
(
value2
);
...
...
This diff is collapsed.
Click to expand it.
histogram.h
+
21
−
5
View file @
bc83bde8
...
...
@@ -25,22 +25,40 @@ namespace MISCMATHS {
class
Histogram
{
public:
Histogram
(){};
const
Histogram
&
operator
=
(
const
Histogram
&
in
){
sourceData
=
in
.
sourceData
;
calcRange
=
in
.
calcRange
;
histMin
=
in
.
histMin
;
histMax
=
in
.
histMax
;
bins
=
in
.
bins
;
return
*
this
;
}
Histogram
(
const
Histogram
&
in
){
*
this
=
in
;}
Histogram
(
const
ColumnVector
&
psourceData
,
int
numBins
)
:
sourceData
(
psourceData
),
calcRange
(
true
),
bins
(
numBins
){}
Histogram
(
const
ColumnVector
&
psourceData
,
float
phistMin
,
float
phistMax
,
int
numBins
)
:
sourceData
(
psourceData
),
calcRange
(
false
),
histMin
(
phistMin
),
histMax
(
phistMax
),
bins
(
numBins
){}
void
set
(
const
ColumnVector
&
psourceData
,
int
numBins
)
{
sourceData
=
psourceData
;
calcRange
=
true
;
bins
=
numBins
;
}
void
set
(
const
ColumnVector
&
psourceData
,
float
phistMin
,
float
phistMax
,
int
numBins
)
{
sourceData
=
psourceData
;
calcRange
=
false
;
histMin
=
phistMin
;
histMax
=
phistMax
;
bins
=
numBins
;
}
void
generate
();
float
getHistMin
()
const
{
return
histMin
;}
float
getHistMax
()
const
{
return
histMax
;}
void
setHistMax
(
float
phistMax
)
{
histMax
=
phistMax
;}
void
setHistMin
(
float
phistMin
)
{
histMin
=
phistMin
;}
void
smooth
();
int
integrateAll
()
{
return
sourceData
.
Nrows
();}
const
ColumnVector
&
getData
()
{
return
histogram
;}
void
setData
(
const
ColumnVector
&
phist
)
{
histogram
=
phist
;}
int
integrateToInf
(
float
value
)
const
{
return
integrate
(
value
,
histMax
);
}
int
integrateFromInf
(
float
value
)
const
{
return
integrate
(
histMin
,
value
);
}
...
...
@@ -54,11 +72,8 @@ namespace MISCMATHS {
protected
:
private
:
Histogram
();
const
Histogram
&
operator
=
(
Histogram
&
);
Histogram
(
Histogram
&
);
const
ColumnVector
&
sourceData
;
ColumnVector
sourceData
;
ColumnVector
histogram
;
bool
calcRange
;
...
...
@@ -71,7 +86,8 @@ namespace MISCMATHS {
inline
int
Histogram
::
getBin
(
float
value
)
const
{
return
Max
(
1
,
Min
((
int
)((((
float
)
bins
)
*
((
float
)(
value
-
histMin
)))
/
((
float
)(
histMax
-
histMin
))),
bins
));
float
binwidth
=
(
histMax
-
histMin
)
/
bins
;
return
Max
(
1
,
Min
((
int
)((((
float
)
bins
)
*
((
float
)(
value
-
(
histMin
-
binwidth
))))
/
((
float
)(
histMax
-
histMin
))),
bins
));
}
inline
float
Histogram
::
getValue
(
int
bin
)
const
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment