diff --git a/cmd/voxel2mesh.cpp b/cmd/voxel2mesh.cpp index e42c18abf6..6cd6b9b47d 100644 --- a/cmd/voxel2mesh.cpp +++ b/cmd/voxel2mesh.cpp @@ -70,8 +70,10 @@ void run () Surface::Algo::image2mesh_blocky (input, mesh); } else { + auto input = Image::open (argument[0]); - const default_type threshold = get_option_value ("threshold", Filter::estimate_optimal_threshold (input)); + auto opt = get_options("threshold"); + const default_type threshold = opt.empty() ? Filter::estimate_optimal_threshold (input) : opt[0][0]; Surface::Algo::image2mesh_mc (input, mesh, threshold); } diff --git a/src/surface/algo/image2mesh.h b/src/surface/algo/image2mesh.h index f9ef180cd0..7415f43dd1 100644 --- a/src/surface/algo/image2mesh.h +++ b/src/surface/algo/image2mesh.h @@ -122,6 +122,7 @@ namespace MR const auto existing = vox2vertindex.find (voxels[in_vertex]); if (existing == vox2vertindex.end()) { triangle_vertices[out_vertex] = vertices.size(); + vox2vertindex.insert(std::make_pair(voxels[in_vertex], vertices.size())); Eigen::Vector3d pos_voxelspace (default_type(voxels[in_vertex][0]) - 0.5, default_type(voxels[in_vertex][1]) - 0.5, default_type(voxels[in_vertex][2]) - 0.5); vertices.push_back (transform.voxel2scanner * pos_voxelspace); } else {