Make layer distance changable. Refs #1.

As a side-effet, now the ordering of the layers is left-to-right rather
than right-to-left. This shouldn't matter in normal processing, but it
is interesting nonetheless.
This commit is contained in:
2018-04-09 14:32:57 +02:00
parent 8cdeefc37b
commit 1c942a7de7
5 changed files with 31 additions and 6 deletions

View File

@@ -16,6 +16,24 @@ static void check_file(const std::string& filename)
}
}
/**
* Create a boost::program_options::value for some variable.
*
* Utility method to make generating value wrappers less repetitive. This
* method automatically sets the default value to whatever the variable
* currently holds.
*
* @tparam T
* @param val Variable to be set/use as default.
* @return A value wrapper
*/
template<typename T>
inline static auto value_for(T& val)
{
return boost::program_options::value<T>(&val)
->default_value(val);
}
/**
* Parse a color string into a color array.
*
@@ -70,9 +88,10 @@ Options::Options(int argc, char * const argv[]):
("network,n", value<std::string>(&modelPath)->required(), "caffe model file for the network")
("labels,l", value<std::string>(&labelsPath), "labels file")
("means,m", value<std::string>(&meansPath), "means file")
("path-color,p", value<std::string>(), "color for paths")
("layer-opacity", value<float>(&layerTransparancy_), "Opacity for layers")
("interaction-opacity", value<float>(&interactionTransparancy_), "Opacity for interactions")
("path-color,p", value<std::string>()->default_value("#ffffff19"), "color for paths")
("layer-opacity", value_for(layerTransparancy_), "Opacity for layers")
("interaction-opacity", value_for(interactionTransparancy_), "Opacity for interactions")
("layer-distance", value_for(LAYER_X_OFFSET), "Distance between layers")
("dump,d", value<std::string>(&dumpPath), "dump convolutional images in this directory");
options_description composed = desc;

View File

@@ -236,7 +236,7 @@ void RenderingState::render(float time) const
glPushMatrix();
glTranslatef(5 * currentData->size(), 0, 0);
glTranslatef(-LAYER_X_OFFSET / 2 * currentData->size(), 0, 0);
for (auto i : Range(currentData->size())) {
glPushMatrix();

View File

@@ -1,7 +1,7 @@
#include <caffe/util/math_functions.hpp>
#include "utils.hpp"
const float fmri::LAYER_X_OFFSET = -10;
float fmri::LAYER_X_OFFSET = 10;
std::default_random_engine &fmri::rng()
{

View File

@@ -21,8 +21,10 @@ namespace fmri
/**
* The distance between layers in the visualisation.
*
* This value is set from the options parser when provided.
*/
extern const float LAYER_X_OFFSET;
extern float LAYER_X_OFFSET;
constexpr const float EPSILON = 1e-10f;