Skip to content

Commit

Permalink
renamed "WatershedDirectional()" to "LabelConnected()", and moved thi…
Browse files Browse the repository at this point in the history
…s function into a file named connect.hpp. Updated the related doxygen comments.
  • Loading branch information
jewettaij committed Jul 27, 2021
1 parent 68685e0 commit 56bc1e9
Show file tree
Hide file tree
Showing 9 changed files with 1,473 additions and 1,417 deletions.
6 changes: 3 additions & 3 deletions bin/filter_mrc/filter_mrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace std;

string g_program_name("filter_mrc");
string g_version_string("0.29.10");
string g_date_string("2021-7-25");
string g_date_string("2021-7-26");



Expand Down Expand Up @@ -540,11 +540,11 @@ int main(int argc, char **argv) {



else if (settings.filter_type == Settings::WATERSHED_DIRECTIONAL) {
else if (settings.filter_type == Settings::LABEL_CONNECTED) {

// Cluster adjacent nearby voxels with high "saliency" into "islands"
// neighboring voxels (this is similar to watershed segmentation).
HandleWatershedDirectional(settings, tomo_in, tomo_out, mask, voxel_width);
HandleLabelConnected(settings, tomo_in, tomo_out, mask, voxel_width);

}

Expand Down
121 changes: 61 additions & 60 deletions bin/filter_mrc/handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ using namespace std;
#include <visfd.hpp>
using namespace visfd;

#include <threshold.hpp>
#include <mrc_simple.hpp>
#include <random_gen.h>
#include <feature.hpp>
#include <morphology.hpp>
#include <segmentation.hpp>
#include <connect.hpp>
#include <draw.hpp>
#include <threshold.hpp>
#include "err.hpp"
#include "settings.hpp"
#include "file_io.hpp"
Expand Down Expand Up @@ -1296,11 +1297,11 @@ HandleWatershed(const Settings &settings,


void
HandleWatershedDirectional(const Settings &settings,
MrcSimple &tomo_in,
MrcSimple &tomo_out,
MrcSimple &mask,
float voxel_width[3])
HandleLabelConnected(const Settings &settings,
MrcSimple &tomo_in,
MrcSimple &tomo_out,
MrcSimple &mask,
float voxel_width[3])
{
const vector<vector<array<float, 3> > > *pMustLinkConstraints = nullptr;

Expand Down Expand Up @@ -1330,32 +1331,32 @@ HandleWatershedDirectional(const Settings &settings,
undefined_voxel_brightness = -1;

size_t num_clusters =
WatershedDirectional(tomo_in.header.nvoxels, //image size
tomo_in.aaafI, //<-saliency
aaaiClusterId, //<-which cluster does each voxel belong to? (results will be stored here)
mask.aaafI,
settings.connect_threshold_saliency,
static_cast<array<float, 3> ***>(nullptr),
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
false, //normal default value for this (ignored) parameter
static_cast<float****>(nullptr),
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
true, //normal default value for this (ignored) parameter
1,
static_cast<ptrdiff_t>(-1), // an impossible value
&cluster_centers,
&cluster_sizes,
&cluster_saliencies,
RegionSortCriteria::SORT_BY_SIZE,
static_cast<float***>(nullptr),
#ifndef DISABLE_STANDARDIZE_VECTOR_DIRECTION
static_cast<array<float, 3> ***>(nullptr),
#endif
pMustLinkConstraints,
true, //(clusters begin at regions of high saliency)
&cerr); //!< print progress to the user
LabelConnected(tomo_in.header.nvoxels, //image size
tomo_in.aaafI, //<-saliency
aaaiClusterId, //<-which cluster does each voxel belong to? (results will be stored here)
mask.aaafI,
settings.connect_threshold_saliency,
static_cast<array<float, 3> ***>(nullptr),
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
false, //normal default value for this (ignored) parameter
static_cast<float****>(nullptr),
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
true, //normal default value for this (ignored) parameter
1,
static_cast<ptrdiff_t>(-1), // an impossible value
&cluster_centers,
&cluster_sizes,
&cluster_saliencies,
RegionSortCriteria::SORT_BY_SIZE,
static_cast<float***>(nullptr),
#ifndef DISABLE_STANDARDIZE_VECTOR_DIRECTION
static_cast<array<float, 3> ***>(nullptr),
#endif
pMustLinkConstraints,
true, //(clusters begin at regions of high saliency)
&cerr); //!< print progress to the user

ptrdiff_t max_label = aaaiClusterId[0][0][0];
for (int iz = 0; iz < image_size[2]; ++iz)
Expand Down Expand Up @@ -1386,7 +1387,7 @@ HandleWatershedDirectional(const Settings &settings,

Dealloc3D(aaaiClusterId);

} //HandleWatershedDirectional()
} //HandleLabelConnected()



Expand Down Expand Up @@ -1858,32 +1859,32 @@ HandleTV(const Settings &settings,

size_t num_clusters =

WatershedDirectional(image_size, //image size
aaafSaliency,
aaaiClusterId, //<-which cluster does each voxel belong to? (results will be stored here)
mask.aaafI,
settings.connect_threshold_saliency,
aaaafDirection,
settings.connect_threshold_vector_saliency,
settings.connect_threshold_vector_neighbor,
false, //eigenvector signs are arbitrary so ignore them
aaaafVoteTensor,
settings.connect_threshold_tensor_saliency,
settings.connect_threshold_tensor_neighbor,
true, //the tensor should be positive definite near the target
1,
static_cast<ptrdiff_t>(-1), // an impossible value
&cluster_centers,
&cluster_sizes,
&cluster_saliencies,
RegionSortCriteria::SORT_BY_SIZE,
static_cast<float***>(nullptr),
#ifndef DISABLE_STANDARDIZE_VECTOR_DIRECTION
aaaafDirection,
#endif
pMustLinkConstraints,
true, //(clusters begin at regions of high saliency)
&cerr); //!< print progress to the user
LabelConnected(image_size, //image size
aaafSaliency,
aaaiClusterId, //<-which cluster does each voxel belong to? (results will be stored here)
mask.aaafI,
settings.connect_threshold_saliency,
aaaafDirection,
settings.connect_threshold_vector_saliency,
settings.connect_threshold_vector_neighbor,
false, //eigenvector signs are arbitrary so ignore them
aaaafVoteTensor,
settings.connect_threshold_tensor_saliency,
settings.connect_threshold_tensor_neighbor,
true, //the tensor should be positive definite near the target
1,
static_cast<ptrdiff_t>(-1), // an impossible value
&cluster_centers,
&cluster_sizes,
&cluster_saliencies,
RegionSortCriteria::SORT_BY_SIZE,
static_cast<float***>(nullptr),
#ifndef DISABLE_STANDARDIZE_VECTOR_DIRECTION
aaaafDirection,
#endif
pMustLinkConstraints,
true, //(clusters begin at regions of high saliency)
&cerr); //!< print progress to the user

ptrdiff_t max_label = aaaiClusterId[0][0][0];
for (int iz = 0; iz < image_size[2]; ++iz)
Expand Down Expand Up @@ -1926,7 +1927,7 @@ HandleTV(const Settings &settings,
// where is the lookup table to indicate which cluster a voxel belongs to?
float ***aaafVoxel2Cluster = nullptr;
if (settings.cluster_connected_voxels)
aaafVoxel2Cluster = tomo_out.aaafI; //tomo_out was filled by WatershedDirectional()
aaafVoxel2Cluster = tomo_out.aaafI; //tomo_out was filled by LabelConnected()

for (int iz = 0; iz < image_size[2]; ++iz) {
for (int iy = 0; iy < image_size[1]; ++iy) {
Expand Down
10 changes: 5 additions & 5 deletions bin/filter_mrc/handlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ HandleWatershed(const Settings &settings,


void
HandleWatershedDirectional(const Settings &settings,
MrcSimple &tomo_in,
MrcSimple &tomo_out,
MrcSimple &mask,
float voxel_width[3]);
HandleLabelConnected(const Settings &settings,
MrcSimple &tomo_in,
MrcSimple &tomo_out,
MrcSimple &mask,
float voxel_width[3]);


void
Expand Down
2 changes: 1 addition & 1 deletion bin/filter_mrc/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,7 @@ Settings::ParseArgs(vector<string>& vArgs)
(filter_type != CURVE))
{
assert(connect_threshold_saliency!=std::numeric_limits<float>::infinity());
filter_type = WATERSHED_DIRECTIONAL;
filter_type = LABEL_CONNECTED;
}


Expand Down
2 changes: 1 addition & 1 deletion bin/filter_mrc/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Settings {
LOG_DOG, // Approximation to Laplacian-of-Guassian using DOG (fast)
LOCAL_FLUCTUATIONS, // Report the fluctuation of nearby voxel intensities
WATERSHED, // Watershed segmentation
WATERSHED_DIRECTIONAL, // Watershed applied to voxels with tensor attributes
LABEL_CONNECTED, // Connected component labeling (count islands in a sea)
BLOB, // Scale-free blob detection
CURVE, // Detect 1D curve-like ridges (a filament detector)
SURFACE_EDGE, // Detect the edge of a light-dark boundary (gradient)
Expand Down
1 change: 0 additions & 1 deletion lib/visfd/clustering.hpp

This file was deleted.

Loading

0 comments on commit 56bc1e9

Please sign in to comment.