From 3ea63f7632f08fa3e2ffed2831dfaa958885b5de Mon Sep 17 00:00:00 2001 From: Andrew Jewett Date: Tue, 20 Jul 2021 09:46:38 -0700 Subject: [PATCH] bug fix: array-bounds error when using the "-normals-file" argument --- bin/filter_mrc/filter_mrc.cpp | 4 ++-- bin/filter_mrc/handlers.cpp | 13 ++++++++++--- doc/doc_filter_mrc.md | 14 ++++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/bin/filter_mrc/filter_mrc.cpp b/bin/filter_mrc/filter_mrc.cpp index 908ba96..a9cd463 100644 --- a/bin/filter_mrc/filter_mrc.cpp +++ b/bin/filter_mrc/filter_mrc.cpp @@ -29,8 +29,8 @@ using namespace std; string g_program_name("filter_mrc"); -string g_version_string("0.29.8"); -string g_date_string("2021-7-19"); +string g_version_string("0.29.9"); +string g_date_string("2021-7-20"); diff --git a/bin/filter_mrc/handlers.cpp b/bin/filter_mrc/handlers.cpp index 65a18c2..1b6c5a5 100644 --- a/bin/filter_mrc/handlers.cpp +++ b/bin/filter_mrc/handlers.cpp @@ -1893,11 +1893,14 @@ HandleTV(const Settings &settings, array drds; array ixyz = {ix, iy, iz}; s = 0.0; - while (//(std::abs(s) <= settings.max_distance_to_feature) && + while ((0 <= ixyz[0]) && (ixyz[0] < image_size[0]) && + (0 <= ixyz[1]) && (ixyz[1] < image_size[1]) && + (0 <= ixyz[2]) && (ixyz[2] < image_size[2]) && + //(std::abs(s) <= settings.max_distance_to_feature) && //(aaafSaliency[ixyz[2]][ixyz[1]][ixyz[0]] >= // settings.connect_threshold_saliency)) - aaafVoxel2Cluster[ixyz[2]][ixyz[1]][ixyz[0]] == - aaafVoxel2Cluster[iz][iy][ix]) + (aaafVoxel2Cluster[ixyz[2]][ixyz[1]][ixyz[0]] == + aaafVoxel2Cluster[iz][iy][ix])) { vS.push_back(s); vxyz.push_back(r); @@ -1928,6 +1931,10 @@ HandleTV(const Settings &settings, r[d] -= ds * drds[d]; ixyz[d] = int(round(r[d])); } + if ((ixyz[0] < 0) || (image_size[0] <= ixyz[0]) || + (ixyz[1] < 0) || (image_size[1] <= ixyz[0]) || + (ixyz[2] < 0) || (image_size[2] <= ixyz[0])) + break; //if ((std::abs(s) > settings.max_distance_to_feature) || // (aaafSaliency[ixyz[2]][ixyz[1]][ixyz[0]] < // settings.connect_threshold_saliency)) diff --git a/doc/doc_filter_mrc.md b/doc/doc_filter_mrc.md index b9bccc9..ddecabb 100644 --- a/doc/doc_filter_mrc.md +++ b/doc/doc_filter_mrc.md @@ -1582,18 +1582,20 @@ The *distance* parameter specifies how far a voxel can be from the surface (or curve) that you are detecting in order for it to be excluded from the file containing the coordinates of that surface (or curve). For example, suppose you are using the "-membrane" or "-edge" arguments -to detect a surface, as well as the "-normals-file" argument +to detect a surface, in addition to the "-normals-file" argument to save that surface to a PLY file. -Voxels that are further than *distance* away from the detected +If you also use "-max-distance-to-feature distance", +it means that voxels that are further than *distance* away from the detected surface will *not* be included in the PLY file that is generated. -(The *distance* parameter has units of physical distance, *not* voxels. + +The *distance* parameter has units of physical distance, *not* voxels. By default, it is equal to 1.5 times the *thickness* parameter used with the "-membrane", "-edge", or "-curve" arguments. -Setting it to "inf" disables this feature.) +Setting it to "inf" disables this feature. *Note that voxels which are not excluded will have their coordinates -projected onto the surface (or curve), regardless of how far away -they are from it.* +projected onto the surface (or curve), in an attempt to make it +as smooth as possible.* ### -max-voxels-to-feature *num_voxels*