-autoscale of data during draw. data remains unchanged
git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@41 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -229,21 +229,45 @@ const VectorXd& DrawComponent::getData ()
|
||||
|
||||
void DrawComponent::setData (const VectorXd& data)
|
||||
{
|
||||
double a;
|
||||
|
||||
m_data = data;
|
||||
DrawData(data);
|
||||
}
|
||||
|
||||
for (int i=0; i < m_height; i++)
|
||||
void DrawComponent::DrawData (const VectorXd& data)
|
||||
{
|
||||
|
||||
double a;
|
||||
VectorXd temp = data;
|
||||
double min = +1E12;
|
||||
double max = -1E12;
|
||||
|
||||
for (int i=0; i < m_width*m_height; i++)
|
||||
{
|
||||
min = std::min<double>(min, (double)temp[i]);
|
||||
max = std::max<double>(max, (double)temp[i]);
|
||||
}
|
||||
for (int i=0; i < m_width*m_height; i++)
|
||||
{
|
||||
temp[i] -= min;
|
||||
}
|
||||
for (int i=0; i < m_width*m_height; i++)
|
||||
{
|
||||
temp[i] /= (max-min);
|
||||
}
|
||||
|
||||
for (int i=0; i < m_height; i++)
|
||||
{
|
||||
for (int j=0; j < m_width; j++)
|
||||
{
|
||||
a = std::min<double>(std::max<double>((double)m_data[i*m_width + j], 0), 1);
|
||||
a = std::min<double>(std::max<double>((double)temp[i*m_width + j], 0), 1);
|
||||
m_pG->setColour(Colour(Colours::white).greyLevel(a));
|
||||
m_pG->fillRect(m_scaleX*j, m_scaleY*i, m_scaleX, m_scaleY);
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
|
||||
}
|
||||
|
||||
//[/MiscUserCode]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user