Go to the documentation of this file.
25 #include <boost/property_tree/ptree.hpp>
26 #include <boost/property_tree/json_parser.hpp>
35 main(
int narg,
char **argv)
37 typedef boost::graph_traits< FEVV::MeshSurface > GraphTraits;
43 std::string input_file_path =
"sphere.obj";
44 if(narg == 2 || narg == 3)
46 std::string reader = std::string(argv[1]);
47 input_file_path = reader;
49 std::string output_file_path =
"just_noticeable_distortion_filter.output.obj";
51 int screen_width = 1920;
52 int screen_height = 1080;
53 double screen_size = 55.;
54 double user_dist = 50.;
55 int scene_width = 1080;
56 double scene_fov = M_PI * 0.3333;
57 int number_of_lights = 128;
61 boost::property_tree::ptree pt;
62 boost::property_tree::read_json(argv[2], pt);
64 screen_width = pt.get<
int >(
"screen_width", screen_width);
65 screen_height = pt.get<
int >(
"screen_height", screen_height);
66 screen_size = pt.get<
double >(
"screen_size", screen_size);
67 user_dist = pt.get<
double >(
"user_dist", user_dist);
68 scene_width = pt.get<
int >(
"scene_width", scene_width);
69 scene_fov = M_PI * pt.get<
double >(
"scene_fov", scene_fov);
70 number_of_lights = pt.get<
int >(
"number_of_lights", number_of_lights);
72 std::cout <<
"Confing used :" << std::endl;
73 std::cout <<
"\tScreen : " << screen_width <<
" * " << screen_height <<
" - "
74 << screen_size << std::endl;
75 std::cout <<
"\tUser distance : " << user_dist << std::endl;
76 std::cout <<
"\tScene : " << scene_width <<
" - " << scene_fov << std::endl;
77 std::cout <<
"\tNumber of lights : " << number_of_lights << std::endl;
80 ScreenParam screen(screen_width, screen_height, screen_size);
89 auto pm =
get(boost::vertex_point, m);
96 using VertexColorMap =
102 std::cout <<
"use existing vertex-color map" << std::endl;
107 std::cout <<
"create vertex-color map" << std::endl;
115 using FaceNormalMap =
121 std::cout <<
"use existing face-normal map" << std::endl;
126 std::cout <<
"create face-normal map" << std::endl;
135 using VertexNormalMap =
138 VertexNormalMap v_nm;
141 std::cout <<
"use existing vertex-normal map" << std::endl;
146 std::cout <<
"create vertex-normal map" << std::endl;
157 jnd_m = FEVV::make_vertex_property_map< FEVV::MeshSurface, double >(m);
161 clock_t t_start = clock();
174 std::cout <<
"Time used to compute JND : "
175 << (double)(clock() - t_start) / CLOCKS_PER_SEC << std::endl;
178 double max_jnd, min_jnd;
186 m, jnd_m, v_cm, min_jnd, max_jnd, lut_courbure_clust);
192 double jnd =
get(jnd_m, vd);
193 std::cout <<
"vertex #" << ++counter;
194 std::cout <<
" - Jnd= " << jnd << std::endl;
void put_property_map(PropertyT p, const MeshT &, PMapsContainer &pmaps, const typename PMap_traits< PropertyT, MeshT >::pmap_type &pmap)
void compute_min_max_vertices(const HalfedgeGraph &g, const PropertyMap &prop_map, MapType &min_metric, MapType &max_metric)
Compute min and max value of a numerical property map for the vertices of a mesh.
PMap_traits< PropertyT, MeshT >::pmap_type get_property_map(PropertyT p, const MeshT &, const PMapsContainer &pmaps)
The parameters of the user.
The parameters of the screen.
bool has_map(const PMapsContainer &pmaps, const std::string &map_name)
(refer to Property Maps API)
The parameters of the scene.
CGAL::Surface_mesh< CGALPoint > MeshSurface
std::map< std::string, boost::any > PMapsContainer
void color_vertices_from_map(const HalfedgeGraph &g, const PropertyMap &prop_map, ColorMap &color_pmap, const MapType min_metric, const MapType max_metric, const ColorMeshLUT &colors=make_LUT())
Fill the color map for the vertices of a mesh using a numerical property map.
ColorMeshLUT make_LUT(bool color_in_0_255=true, unsigned int colors_nbr=256, float h1=240, float h2=0)
Create a RGB LUT based on an HSV range. Default range creates a blue-cyan-green-yellow-red gradient.
std::vector< float > ColorMeshLUT
void read_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps, bool=false)
Load mesh from file.
void calculate_face_normals(const HalfedgeGraph &g, const PointMap &pm, FaceNormalMap fnm, const GeometryTraits >)
Calculate "some" normal of all the faces of the considered mesh and populate the argument provided Fa...
void write_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps)
Write mesh to file.
void calculate_vertex_normals(const HalfedgeGraph &g, const PointMap &pm, const FaceNormalMap &fnm, VertexNormalMap vnm, const GeometryTraits >)
Compute the respectice vertex normal for all the vertices of the considered mesh and populate the arg...
boost::property_map< FEVV::DataStructures::AIF::AIFMesh, boost::vertex_index_t >::const_type get(const boost::vertex_index_t &, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the vertex index property map of the mesh.
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
int main(int narg, char **argv)
void just_noticeable_distortion_filter(const HalfedgeGraph &halfedge_graph, PointMap &point_map, const VertexNormalMap &vertex_normal_map, const GeometryTraits &geometry_traits, const FaceNormalMap &face_normal_map, JNDMap &jnd_map, const ScreenParam &screen, const UserParam &user, const SceneParam &scene, const int nb_light_sources, bool data_output=false, bool use_random=true)
Computes the Just Noticeable Distortion metric.
PMap_traits< PropertyT, MeshT >::pmap_type make_property_map(PropertyT, const MeshT &m)