int main() { // Import CT image ImageFileImporter::pointer importer = ImageFileImporter::New(); importer->setFilename(Config::getTestDataPath() + "CT/CT-Abdomen.mhd"); // Extract surface mesh from the CT image SurfaceExtraction::pointer extraction = SurfaceExtraction::New(); extraction->setInputConnection(importer->getOutputPort()); extraction->setThreshold(400); // Export mesh to disk VTKMeshFileExporter::pointer exporter = VTKMeshFileExporter::New(); exporter->setInputConnection(extraction->getOutputPort()); exporter->setFilename("region_growing_result.vtk"); exporter->setWriteNormals(true); exporter->update(0); }
int main() { // Import CT image ImageFileImporter::pointer importer = ImageFileImporter::New(); importer->setFilename(std::string(FAST_TEST_DATA_DIR) + "CT-Abdomen.mhd"); // Extract surface mesh using a threshold value SurfaceExtraction::pointer extraction = SurfaceExtraction::New(); extraction->setInputConnection(importer->getOutputPort()); extraction->setThreshold(300); // Render and visualize the mesh MeshRenderer::pointer surfaceRenderer = MeshRenderer::New(); surfaceRenderer->setInputConnection(extraction->getOutputPort()); SimpleWindow::pointer window = SimpleWindow::New(); window->addRenderer(surfaceRenderer); #ifdef FAST_CONTINUOUS_INTEGRATION // This will automatically close the window after 5 seconds, used for CI testing window->setTimeout(5*1000); #endif window->start(); }