Skip to content

Commit

Permalink
bug fix: array-bounds error when using the "-normals-file" argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jewettaij committed Jul 20, 2021
1 parent f0a6f4d commit 3ea63f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/filter_mrc/filter_mrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");



Expand Down
13 changes: 10 additions & 3 deletions bin/filter_mrc/handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,11 +1893,14 @@ HandleTV(const Settings &settings,
array<float, 3> drds;
array<int, 3> 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);
Expand Down Expand Up @@ -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))
Expand Down
14 changes: 8 additions & 6 deletions doc/doc_filter_mrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down

0 comments on commit 3ea63f7

Please sign in to comment.