Beispiel #1
0
int main() {
    // Import two point sets A and B
    VTKPointSetFileImporter::pointer importerA = VTKPointSetFileImporter::New();
    importerA->setFilename(Config::getTestDataPath() + "Surface_LV.vtk");

    VTKPointSetFileImporter::pointer importerB = VTKPointSetFileImporter::New();
    importerB->setFilename(Config::getTestDataPath() + "Surface_LV.vtk");

    // Apply a transformation to point set B
    Vector3f translation(0.01, 0, 0.01);
    Vector3f rotation(0.5, 0, 0);
    AffineTransformation::pointer transformation = AffineTransformation::New();
    transformation->getTransform().translate(translation);
    Matrix3f R;
    R = Eigen::AngleAxisf(rotation.x(), Vector3f::UnitX())
    * Eigen::AngleAxisf(rotation.y(), Vector3f::UnitY())
    * Eigen::AngleAxisf(rotation.z(), Vector3f::UnitZ());
    transformation->getTransform()->rotate(R);
    importerB->update();
    importerB->getOutputData<PointSet>()->getSceneGraphNode()->setTransformation(transformation);

    // Perform the registration
    IterativeClosestPoint::pointer icp = IterativeClosestPoint::New();
    icp->setMovingPointSetPort(importerA->getOutputPort());
    icp->setFixedPointSetPort(importerB->getOutputPort());
    icp->update();

    // Apply transformation to A
    importerA->getOutputData<PointSet>()->getSceneGraphNode()->setTransformation(icp->getOutputTransformation());

    Reporter::info() << "Registration result: " << Reporter::end();
    Reporter::info() << "Rotation: " << icp->getOutputTransformation()->getEulerAngles().transpose() << Reporter::end();
    Reporter::info() << "Translation:" << icp->getOutputTransformation()->getTransform().translation().transpose() << Reporter::end();

    // Visualize the two point sets
    VertexRenderer::pointer renderer = VertexRenderer::New();
    renderer->addInputConnection(importerA->getOutputPort(), Color::Blue(), 10);
    renderer->addInputConnection(importerB->getOutputPort(), Color::Green(), 5);
    renderer->setDefaultDrawOnTop(true);

    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
	// This will automatically close the window after 5 seconds, used for CI testing
    window->setTimeout(5*1000);
#endif
    window->start();
}
int main() {
    // Import images from files using the ImageFileStreamer
    ImageFileStreamer::pointer streamer = ImageFileStreamer::New();
    // The hashtag here will be replaced with an integer, starting with 0 as default
    streamer->setFilenameFormat(std::string(FAST_TEST_DATA_DIR)+"/US-2Dt/US-2Dt_#.mhd");

    // Renderer image
    ImageRenderer::pointer renderer = ImageRenderer::New();
    renderer->addInputConnection(streamer->getOutputPort());
    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
    window->set2DMode();
#ifdef FAST_CONTINUOUS_INTEGRATION
	// This will automatically close the window after 5 seconds, used for CI testing
    window->setTimeout(5*1000);
#endif
    window->start();
}
Beispiel #3
0
int main(int argc, char** argv) {
    CommandLineParser parser("Import triangle mesh from file");
    parser.addPositionVariable(1, "filename", Config::getTestDataPath()+"/Surface_LV.vtk");
    parser.parse(argc, argv);

    // Import a triangle mesh from vtk file using the VTKMeshFileImporter
    VTKMeshFileImporter::pointer importer = VTKMeshFileImporter::New();
    importer->setFilename(parser.get("filename"));

    // Renderer mesh
    TriangleRenderer::pointer renderer = TriangleRenderer::New();
    renderer->addInputConnection(importer->getOutputPort());

    // Setup window
    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
    window->setTimeout(5*1000); // automatically close window after 5 seconds
#endif
    window->start();
}
int main() {
    // Import image from file using the ImageFileImporter
    ImageFileImporter::pointer importer = ImageFileImporter::New();
    importer->setFilename(std::string(FAST_TEST_DATA_DIR)+"/US-2D.jpg");

    // Smooth image
    GaussianSmoothingFilter::pointer filter = GaussianSmoothingFilter::New();
    filter->setInputConnection(importer->getOutputPort());
    filter->setStandardDeviation(2.0);
    filter->setMaskSize(7);

    // Renderer image
    ImageRenderer::pointer renderer = ImageRenderer::New();
    renderer->addInputConnection(filter->getOutputPort());
    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
	// This will automatically close the window after 5 seconds, used for CI testing
    window->setTimeout(5*1000);
#endif
    window->start();
}
int main(int argc, char** argv) {
    CommandLineParser parser("Import point set from file");
    parser.addPositionVariable(1, "filename", Config::getTestDataPath() + "Surface_LV.vtk");
    parser.parse(argc, argv);

    // Import line set from vtk file
    VTKMeshFileImporter::pointer importer = VTKMeshFileImporter::New();
    importer->setFilename(parser.get("filename"));

    // Render vertices
    VertexRenderer::pointer renderer = VertexRenderer::New();
    renderer->addInputConnection(importer->getOutputPort());

    // Setup window
    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
	// This will automatically close the window after 5 seconds, used for CI testing
    window->setTimeout(5*1000);
#endif
    window->start();
}
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();
}
Beispiel #7
0
int main() {
    // Import image from file using the ImageFileImporter
    ImageFileImporter::pointer importer = ImageFileImporter::New();
    importer->setFilename(std::string(FAST_TEST_DATA_DIR)+"/US-2D.jpg");
    //importer->setFilename(std::string(FAST_TEST_DATA_DIR) + "/US-1-2D.png");
    
    /*
    //K = 1, dvs K = gamle versjonen, M_PI gaus
    int groupSize = 5;
    int windowSize = 51;
    float sigma = 1.65f;
    float dS = 0.5f;
    */
    /*
    //K = 0, dvs K = 1/2d
    int groupSize = 5;
    int windowSize = 51;
    float sigma = 0.65f;
    float dS = 0.135f;
    */
    //K = 3 dvs ny gauss
    int groupSize = 17;
    int windowSize = 17;
    float sigma = 5.000f;
    //float dS = 0.03999f;
    float dS = 5.0f;
    
    // Smooth image
    NoneLocalMeans::pointer filter = NoneLocalMeans::New();
    filter->setInputConnection(importer->getOutputPort());
    //filter->setGroupSize(15);
    //filter->setWindowSize(51);
    //filter->setSigma(0.15f);
    //filter->setDenoiseStrength(0.15f);
    filter->setGroupSize(groupSize);
    filter->setWindowSize(windowSize);
    filter->setSigma(sigma);
    filter->setDenoiseStrength(dS);
    filter->setEuclid(1);
    filter->setK(2);
    //filter->setOutputType(TYPE_FLOAT);
    
    //Export img
    ImageExporter::pointer exporter = ImageExporter::New();
    std::string text = "";
    //text += std::to_string( groupSize );
    //text += "WS_";
    //text += std::to_string( windowSize );
    //text += "S_";
    //text += std::to_string( sigma );
    //text += "DS_";
    //text += std::to_string( dS );
    text += "TIME_";
    time_t seconds;
    seconds = time (NULL);
    text += std::to_string( seconds );
    text += ".jpg";
    exporter->setFilename(text);
    exporter->setInputConnection(filter->getOutputPort());
    exporter->update();
    
    // Renderer image
    ImageRenderer::pointer renderer = ImageRenderer::New();
    renderer->addInputConnection(filter->getOutputPort());
    SimpleWindow::pointer window = SimpleWindow::New();
    window->addRenderer(renderer);
    window->setTimeout(200*1000); // automatically close window after 5 seconds
    window->start();
}