コード例 #1
0
ファイル: DistanceTransform.cpp プロジェクト: SqLL/DGtal_PRED
int main()
{
    const std::string examplesPath= "/home/remi/pred/DGtal_PRED/Source/Experience/";
    std::string filename =  examplesPath + "samples/contourS.pgm";
    Image image = DGtal::PNMReader<Image>::importPGM(filename);
    DGtal::trace.info() << "Imported image: "<<image<<endl;


    DGtal::Board2D aBoard;
    aBoard << image.domain();
    aBoard.saveSVG("imageDomainTuto.svg");
    aBoard.clear();
    Display2DFactory::drawImage<Gray>(aBoard, image, (unsigned char)0, (unsigned char)255);
    aBoard.saveEPS("imageDomainTuto2.eps");


    typedef IntervalForegroundPredicate<Image> Binarizer;
    Binarizer b(image,1, 135);
    typedef DGtal::DistanceTransformation<Z2i::Space, Binarizer, 2> DTL2;
    typedef DTL2::OutputImage OutputImage;
    DTL2 dt(image.domain(),b);

    OutputImage result = dt.compute();

    OutputImage::Value maxDT = (*std::max_element(result.begin(),
                                result.end()));
    typedef DGtal::HueShadeColorMap<OutputImage::Value,2> HueTwice;

    aBoard.clear();
    Display2DFactory::drawImage<HueTwice>(aBoard, result, (OutputImage::Value)0, (OutputImage::Value)maxDT);
    aBoard.saveEPS("imageDomainTuto3.eps");
}
コード例 #2
0
ファイル: shapeDTViewer.cpp プロジェクト: VincentPlasse/DGtal
int main(int argc, char **argv)
{
    QApplication application(argc,argv);

    DGtal::Viewer3D viewer;

    DGtal::Z3i::Point center(0,0,0);
    DGtal::ImplicitRoundedHyperCube<Z3i::Space> myCube( center, 20, 2.8);
    DGtal::Z3i::Domain domain(myCube.getLowerBound(),
                              myCube.getUpperBound());

    DGtal::Z3i::DigitalSet mySet(domain);

    DGtal::Shapes<DGtal::Z3i::Domain>::euclideanShaper( mySet, myCube);


    viewer.show();
    // viewer << mySet << DGtal::Display3D::updateDisplay;


    //! [ImageSetDT-DT]
    typedef DGtal::SetPredicate<DGtal::Z3i::DigitalSet> Predicate;
    Predicate aPredicate(mySet);

    typedef DGtal::DistanceTransformation<Z3i::Space, Predicate, 2> DTL2;
    typedef DTL2::OutputImage OutputImage;
    DTL2 dt(domain,aPredicate);

    OutputImage result = dt.compute();
    //! [ImageSetDT-DT]

    OutputImage::Value maxDT = (*std::max_element(result.begin(),
                                result.end()));


    GradientColorMap<OutputImage::Value> gradient( 0, maxDT);
    gradient.addColor(DGtal::Color::Blue);
    gradient.addColor(DGtal::Color::Green);
    gradient.addColor(DGtal::Color::Yellow);
    gradient.addColor(DGtal::Color::Red);


    for(Z3i::Domain::ConstIterator it = domain.begin(),
            itend = domain.end(); it != itend;
            ++it)
        if (result(*it) != 0)
        {
            OutputImage::Value  val= result( *it );
            DGtal::Color c= gradient(val);

            viewer <<  DGtal::CustomColors3D(c,c) << *it    ;

        }


    viewer << DGtal::ClippingPlane(1,0,0,0);
    //@todo updateDisplay is in Display3D or Viewer3D (cf doc)?
    viewer << DGtal::Display3D::updateDisplay;

    return application.exec();


}