Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
408c9a89
Commit
408c9a89
authored
Jul 12, 2012
by
Mario Hlawitschka
Browse files
[ADD] added non-logarithmic histogram on top of logarithmic histogram
parent
59218af8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
11 deletions
+37
-11
src/qt4gui/qt4/controlPanel/transferFunction/WTransferFunctionHistogram.cpp
...trolPanel/transferFunction/WTransferFunctionHistogram.cpp
+37
-11
No files found.
src/qt4gui/qt4/controlPanel/transferFunction/WTransferFunctionHistogram.cpp
View file @
408c9a89
...
...
@@ -37,7 +37,7 @@
WTransferFunctionHistogram
::
WTransferFunctionHistogram
(
WTransferFunctionWidget
*
/*parent*/
)
:
BaseClass
()
{
setOpacity
(
0.
3
);
setOpacity
(
0.
4
);
setZValue
(
2
);
}
...
...
@@ -65,19 +65,45 @@ void WTransferFunctionHistogram::paint( QPainter *painter, const QStyleOptionGra
painter
->
setBrush
(
gradient
);
QPolygon
histogram
;
QRectF
bb
(
this
->
scene
()
->
sceneRect
()
);
histogram
<<
QPoint
(
bb
.
right
(),
bb
.
bottom
()
);
histogram
<<
QPoint
(
bb
.
left
(),
bb
.
bottom
()
);
// polygon for logarithmic mapping ( background )
{
QPolygon
histogram
;
QRectF
bb
(
this
->
scene
()
->
sceneRect
()
);
histogram
<<
QPoint
(
bb
.
right
(),
bb
.
bottom
()
);
histogram
<<
QPoint
(
bb
.
left
(),
bb
.
bottom
()
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
// logarithmic mapping of histogram to values
// the added 0.001 is to avoid numerical problems but should work for most data sets
// when changing this value, keep in mind that the value has to work for a wide range of
// numbers ( i.e. maxval close to 0 and maxval close to infty )
histogram
<<
QPoint
(
bb
.
left
()
+
(
double
)
bb
.
width
()
*
(
double
)
i
/
(
double
)
steps
,
bb
.
bottom
()
-
(
double
)
bb
.
height
()
*
std
::
log
(
m_data
[
i
]
+
1
)
/
std
::
log
(
maxval
+
1
+
0.001
)
);
}
painter
->
drawPolygon
(
histogram
);
}
// The paper "Multi-Dimensional Transfer Functions for Interactive Volume Rendering"
// by Joe Kniss, Gordon Kindlmann and Charles Hansen
// brought the idea of overlaying the logarithmic plot with a non-logarithmic plot
// which may help to understand the data a bit better. Maybe this should be a config option,
// but for now it is there for whoever likes to see it.
//
// polygon for non-logarithmic mapping
{
// logarithmic mapping of histogram to values
// the added 1.001 is to avoid numerical problems but should work for most data sets
histogram
<<
QPoint
(
bb
.
left
()
+
(
double
)
bb
.
width
()
*
(
double
)
i
/
(
double
)
steps
,
bb
.
bottom
()
-
(
double
)
bb
.
height
()
*
std
::
log
(
m_data
[
i
]
+
1
)
/
std
::
log
(
maxval
+
1.001
)
);
QPolygon
histogram
;
QRectF
bb
(
this
->
scene
()
->
sceneRect
()
);
histogram
<<
QPoint
(
bb
.
right
(),
bb
.
bottom
()
);
histogram
<<
QPoint
(
bb
.
left
(),
bb
.
bottom
()
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
// linear mapping of histogram to values
histogram
<<
QPoint
(
bb
.
left
()
+
(
double
)
bb
.
width
()
*
(
double
)
i
/
(
double
)
steps
,
bb
.
bottom
()
-
(
double
)
bb
.
height
()
*
m_data
[
i
]
/
maxval
);
}
painter
->
drawPolygon
(
histogram
);
}
painter
->
drawPolygon
(
histogram
);
}
}
}
...
...
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