Skip to content

Commit

Permalink
added the -dilation, -erosion, -openning, -closing morphological filt…
Browse files Browse the repository at this point in the history
…ers to VISFD and filter_mrc. (Documented and tested, but not yet included in the testing scripts.)
  • Loading branch information
jewettaij committed Jul 12, 2021
1 parent 9e666f0 commit 06698cc
Show file tree
Hide file tree
Showing 8 changed files with 2,099 additions and 1,696 deletions.
194 changes: 130 additions & 64 deletions bin/filter_mrc/filter_mrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace std;


string g_program_name("filter_mrc");
string g_version_string("0.28.1");
string g_version_string("0.28.2");
string g_date_string("2021-7-11");


Expand Down Expand Up @@ -367,193 +367,259 @@ int main(int argc, char **argv) {
"Use the -w argument to specify the voxel width.");


// ---- filtering ----
// perform an operation which generates a new image based on the old image

// ---- Select the primary operation we will perform on the image ----



if (settings.filter_type == Settings::NONE) {

cerr << "filter_type = Intensity Map <No convolution filter specified>\n";
// Not needed:
//for (int iz = 0; iz < size[2]; iz++)
// for (int iy = 0; iy < size[1]; iy++)
// for (int ix = 0; ix < size[0]; ix++)
// tomo_out.aaafI[iz][iy][ix]=tomo_in.aaafI[iz][iy][ix];
// (We have copied the contents from tomo_in into tomo_out already.)

}



else if (settings.filter_type == Settings::DILATION) {

// Apply a greyscale dilation filter to the image.
HandleDilation(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::EROSION) {

// Apply a greyscale erosion filter to the image.
HandleErosion(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::OPENING) {

// Apply a greyscale opening filter to the image.
HandleOpening(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::CLOSING) {

// Apply a greyscale closing filter to the image.
HandleClosing(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::GAUSS) {

// Apply a Gaussian filter to the image.
HandleGauss(settings, tomo_in, tomo_out, mask, voxel_width);
} // if (settings.filter_type == Settings::GAUSS)

}



else if (settings.filter_type == Settings::GGAUSS) {

// Apply a generalized Gaussian filter
HandleGGauss(settings, tomo_in, tomo_out, mask, voxel_width);

} //else if (settings.filter_type == Settings::GGAUSS)
}



else if (settings.filter_type == Settings::DOG) {

// Apply a Difference-of-Gaussians filter
HandleDog(settings, tomo_in, tomo_out, mask, voxel_width);

} //if (settings.filter_type == Settings::DOG)
}



else if (settings.filter_type == Settings::DOGG) {

// Apply a generalized DoG filter.
// (Note: This kind of operation is probably not useful.
// I may remove this feature in the future. -Andrew 2021-7-11)
HandleDogg(settings, tomo_in, tomo_out, mask, voxel_width);

} //if (settings.filter_type == Settings::DOGG)
}



#ifndef DISABLE_DOGGXY
else if (settings.filter_type == Settings::DOGGXY) {

// Apply a generalized DoG filter in the XY direction
// and a Gaussian filter in the Z direction.
HandleDoggXY(settings, tomo_in, tomo_out, mask, voxel_width);

} //else if (settings.filter_type = Settings::DOGGXY)
}
#endif



else if (settings.filter_type == Settings::LOG_DOG) {

// Apply a LoG filter (implemented using the DoG approximation).
HandleLoGDoG(settings, tomo_in, tomo_out, mask, voxel_width);

} //if (settings.filter_type == Settings::DOG_SCALE_FREE)

}


else if (settings.filter_type == Settings::BLOB) {

HandleBlobDetector(settings, tomo_in, tomo_out, mask, voxel_width);

} //if (settings.filter_type == Settings::DOG)
}



else if ((settings.filter_type == Settings::SURFACE_EDGE) ||
(settings.filter_type == Settings::SURFACE_RIDGE) ||
(settings.filter_type == Settings::CURVE)) {

// find surface ridges (ie membranes or wide tubes)
// Detect 2-D surfaces or 1-D curves
HandleTV(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::WATERSHED) {

// perform watershed segmentation
// Perform watershed segmentation
HandleWatershed(settings, tomo_in, tomo_out, mask, voxel_width);

}



else if (settings.filter_type == Settings::CLUSTER_CONNECTED) {

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

}



else if (settings.filter_type == Settings::LOCAL_FLUCTUATIONS) {

// Apply a filter that measures the amount of brightness fluctuations
// in the local neighborhood.
HandleLocalFluctuations(settings, tomo_in, tomo_out, mask, voxel_width);

} //else if (settings.filter_type == Settings::TEMPLATE_GGAUSS)
}


// ----- distance_filter -----

else if (settings.filter_type == settings.DISTANCE_TO_POINTS) {

// Apply a filter which replaces the voxel brightness with the distance
// to the nearest poing in a (user-supplied) point cloud.
HandleDistanceToPoints(settings, tomo_in, tomo_out, mask, voxel_width);

// ----- template matching with error reporting (probably not useful) -----
}


else if (settings.filter_type == Settings::TEMPLATE_GGAUSS) {
// ----- sphere_decals_filter -----

#ifndef DISABLE_TEMPLATE_MATCHING
HandleTemplateGGauss(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING
else if (settings.filter_type == settings.SPHERE_DECALS) {

} //else if (settings.filter_type == Settings::TEMPLATE_GGAUSS)
// Draw a new image or annotate (draw on top of) an existing image.
HandleDrawSpheres(settings, tomo_in, tomo_out, mask, voxel_width);

}


else if (settings.filter_type == Settings::TEMPLATE_GAUSS) {
else if (settings.filter_type == settings.SPHERE_NONMAX_SUPPRESSION) {

#ifndef DISABLE_TEMPLATE_MATCHING
HandleTemplateGauss(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING
vector<array<float,3> > crds;
vector<float> diameters;
vector<float> scores;

} //else if (settings.filter_type == Settings::TEMPLATE_GAUSS)
// Discard overlapping or poor scoring blobs from a (user-supplied) list.
// (Note: In this case, we are not analyzing the image.
// The list of blobs is supplied by the user, most likely by
// running this program at an earlier time using the "-blob"
// argument.)
HandleBlobsNonmaxSuppression(settings,
mask,
voxel_width,
crds,
diameters,
scores);

}

else if (settings.filter_type == Settings::BLOB_RADIAL_INTENSITY) {

#ifndef DISABLE_INTENSITY_PROFILES
HandleBlobRadialIntensity(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING
else if (settings.filter_type == settings.SPHERE_NONMAX_SUPERVISED_MULTI) {

} //else if (settings.filter_type == Settings::TEMPLATE_GAUSS)
// Use training data to choose the right threshold(s) for discarding blobs
HandleBlobScoreSupervisedMulti(settings,
voxel_width);
}




else if (settings.filter_type == Settings::BOOTSTRAP_DOGG) {
// ------- DEPRECIATED FEATURES -------

#ifdef DISABLE_BOOSTRAPPING
HandleBootstrappDogg(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_BOOTSTRAPPING

} //else if (settings.filter_type == Settings::BOOTSTRAP_DOGG) {
else if (settings.filter_type == Settings::TEMPLATE_GGAUSS) {

#ifndef DISABLE_TEMPLATE_MATCHING
// Spherical template matching with RMS error reporting.
// (Not very useful. I may remove this feature in the future -A 2021-7-11)
HandleTemplateGGauss(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING

// ----- distance_filter -----
}

else if (settings.filter_type == settings.DISTANCE_TO_POINTS) {

HandleDistanceToPoints(settings, tomo_in, tomo_out, mask, voxel_width);
else if (settings.filter_type == Settings::TEMPLATE_GAUSS) {

#ifndef DISABLE_TEMPLATE_MATCHING
// Spherical template matching with RMS error reporting.
// (Not very useful. I may remove this feature in the future -A 2021-7-11)
HandleTemplateGauss(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING

}

// ----- sphere_decals_filter -----

else if (settings.filter_type == settings.SPHERE_DECALS) {
else if (settings.filter_type == Settings::BOOTSTRAP_DOGG) {

HandleDrawSpheres(settings, tomo_in, tomo_out, mask, voxel_width);
#ifdef DISABLE_BOOSTRAPPING
// (I may remove this feature in the future -Andrew 2021-7-11)
HandleBootstrappDogg(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_BOOTSTRAPPING

}

else if (settings.filter_type == settings.SPHERE_NONMAX_SUPPRESSION) {

vector<array<float,3> > crds;
vector<float> diameters;
vector<float> scores;
else if (settings.filter_type == Settings::BLOB_RADIAL_INTENSITY) {

HandleBlobsNonmaxSuppression(settings,
mask,
voxel_width,
crds,
diameters,
scores);
#ifndef DISABLE_INTENSITY_PROFILES
// This is a feature that a user requested for a specific project.
// It is probably not relevant to most users.
// (I may remove this feature in the future -Andrew 2021-7-11)
HandleBlobRadialIntensity(settings, tomo_in, tomo_out, mask, voxel_width);
#endif //#ifndef DISABLE_TEMPLATE_MATCHING

}

else if (settings.filter_type == settings.SPHERE_NONMAX_SUPERVISED_MULTI) {

HandleBlobScoreSupervisedMulti(settings,
voxel_width);
}

else {
assert(false); //should be one of the choices above
Expand Down
Loading

0 comments on commit 06698cc

Please sign in to comment.