-
Notifications
You must be signed in to change notification settings - Fork 103
Example: Airway segmentation and centerline extraction
Erik Smistad edited this page Apr 12, 2016
·
2 revisions
/**
* Examples/Segmentation/airwaySegmentation.cpp
*
* If you edit this example, please also update the wiki and source code file in the repository.
*/
#include "FAST/Algorithms/AirwaySegmentation/AirwaySegmentation.hpp"
#include "FAST/Importers/ImageFileImporter.hpp"
#include "FAST/Algorithms/SurfaceExtraction/SurfaceExtraction.hpp"
#include "FAST/Algorithms/CenterlineExtraction/CenterlineExtraction.hpp"
#include "FAST/Visualization/MeshRenderer/MeshRenderer.hpp"
#include "FAST/Visualization/LineRenderer/LineRenderer.hpp"
#include "FAST/Visualization/SimpleWindow.hpp"
#include "FAST/TestDataPath.hpp"
using namespace fast;
int main() {
// Import CT data
ImageFileImporter::pointer importer = ImageFileImporter::New();
importer->setFilename(std::string(FAST_TEST_DATA_DIR) + "CT-Thorax.mhd");
// Do airway segmenetation
AirwaySegmentation::pointer segmentation = AirwaySegmentation::New();
segmentation->setInputConnection(importer->getOutputPort());
// Extract centerline from segmentation
CenterlineExtraction::pointer centerline = CenterlineExtraction::New();
centerline->setInputConnection(segmentation->getOutputPort());
centerline->update();
// Extract surface from segmentation
SurfaceExtraction::pointer extraction = SurfaceExtraction::New();
extraction->setInputConnection(segmentation->getOutputPort());
// Set up renderers and window
MeshRenderer::pointer renderer = MeshRenderer::New();
renderer->addInputConnection(extraction->getOutputPort());
LineRenderer::pointer lineRenderer = LineRenderer::New();
lineRenderer->addInputConnection(centerline->getOutputPort());
lineRenderer->setDefaultDrawOnTop(true);
SimpleWindow::pointer window = SimpleWindow::New();
window->addRenderer(renderer);
window->addRenderer(lineRenderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
// This will automatically close the window after 5 seconds, used for CI testing
window->setTimeout(5*1000);
#endif
window->start();
}
If this wiki page lacks some information or is incorrect please let us know! You can edit this wiki page yourself, send an email to ersmistad@gmail.com or