int main( int argc, char** argv ) { QApplication application(argc,argv); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); Point p1( 0, 0, 0 ); Point p2( 20, 20, 20 ); Domain domain(p1, p2); DigitalSet shape_set( domain ); Shapes<Domain>::addNorm2Ball( shape_set, Point( 10, 10, 10 ), 7 ); viewer << SetMode3D( shape_set.className(), "Both" ); viewer << shape_set; viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 200,0, 20)); viewer << SetMode3D( p1.className(), "Paving" ); viewer << ClippingPlane(1,0,0,-4.9); viewer << ClippingPlane(0,1,0.3,-10); viewer << MyViewer::updateDisplay; return application.exec(); }
int main( int argc, char** argv ) { typedef DGtal::ImageContainerBySTLVector<DGtal::Z3i::Domain, unsigned char > Image3D; //! [ExampleViewer3D2DImagesExtractImagesNonSliceType] typedef DGtal::ConstImageAdapter<Image3D, Z2i::Domain, DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain>, Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor; //! [ExampleViewer3D2DImagesExtractImagesNonSliceType] QApplication application(argc,argv); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); std::string inputFilename = examplesPath + "samples/lobster.vol"; Image3D imageVol = VolReader<Image3D>::importVol(inputFilename); DGtal::functors::Identity idV; //! [ExampleViewer3D2DImagesExtractImagesNonSliceParam] DGtal::Z3i::Point ptCenter(50, 62, 28); const int IMAGE_PATCH_WIDTH = 20; // Setting the image domain of the resulting image to be displayed in 3D: DGtal::Z2i::Domain domainImage2D (DGtal::Z2i::Point(0,0), DGtal::Z2i::Point(IMAGE_PATCH_WIDTH, IMAGE_PATCH_WIDTH)); //! [ExampleViewer3D2DImagesExtractImagesNonSliceParam] unsigned int pos=0; for (double alpha = 0; alpha< 1.54; alpha+= 0.01){ //! [ExampleViewer3D2DImagesExtractImagesNonSliceExtract] // Extracting images from 3D embeder DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain > embedder(imageVol.domain(), ptCenter+DGtal::Z3i::Point(static_cast<int>(200.0*cos(alpha)),static_cast<int>(100.0*sin(alpha))), DGtal::Z3i::RealPoint(cos(alpha),sin(alpha),cos(2.0*alpha)), IMAGE_PATCH_WIDTH); ImageAdapterExtractor extractedImage(imageVol, domainImage2D, embedder, idV); //! [ExampleViewer3D2DImagesExtractImagesNonSliceExtract] //! [ExampleViewer3D2DImagesExtractImagesNonSliceDisplay] //Display image and update its position with embeder viewer << extractedImage; viewer << DGtal::UpdateImage3DEmbedding<Z3i::Space, Z3i::KSpace>(pos, embedder(Z2i::RealPoint(0,0)), embedder(Z2i::RealPoint(IMAGE_PATCH_WIDTH,0)), embedder(domainImage2D.upperBound()), embedder(Z2i::RealPoint(0, IMAGE_PATCH_WIDTH))); //! [ExampleViewer3D2DImagesExtractImagesNonSliceDisplay] pos++; } viewer << MyViewer::updateDisplay; return application.exec(); }
int main( int argc, char** argv ) { typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char > Image3D; QApplication application(argc,argv); typedef Viewer3D<> MyViewer ; MyViewer viewer; viewer.show(); std::string inputFilename = examplesPath + "samples/lobster.vol"; Image3D imageVol = GenericReader<Image3D>::import(inputFilename); Z3i::Point ptLow (100, 100, 20); Z3i::Point ptUpp (200, 200, 40); Z3i::Domain subDomain(ptLow, ptUpp); Z3i::Point ptLow2 (220, 50, 10); Z3i::Point ptUpp2 (260, 100, 20); Z3i::Domain subDomain2(ptLow2, ptUpp2); Image3D imageCrop(subDomain); Image3D imageCrop2(subDomain2); for(Z3i::Domain::ConstIterator it= imageVol.domain().begin(), itend = imageVol.domain().end(); it != itend; ++it){ if(imageVol(*it)>140) viewer << *it; Z3i::Point pt = *it; if(pt[0]>=ptLow[0] && pt[1] >= ptLow[1] && pt[2] >= ptLow[2] && pt[0]<=ptUpp[0] && pt[1] <= ptUpp[1] && pt[2] <= ptUpp[2]){ imageCrop.setValue(*it, imageVol(*it)); } if(pt[0]>=ptLow2[0] && pt[1] >= ptLow2[1] && pt[2] >= ptLow2[2] && pt[0]<=ptUpp2[0] && pt[1] <= ptUpp2[1] && pt[2] <= ptUpp2[2]){ imageCrop2.setValue(*it, imageVol(*it)); } } viewer << imageCrop; viewer << SetMode3D(imageCrop.className(), "BoundingBox"); //! [ExampleViewer3D3DImagesDisplayImagesColor] viewer << AddTextureImage3DWithFunctor<Image3D, hueFct, Z3i::Space, Z3i::KSpace> (imageCrop2, hueFct(), MyViewer::RGBMode); viewer << MyViewer::updateDisplay; //! [ExampleViewer3D3DImagesDisplayImagesColor] return application.exec(); }
int main( int argc, char** argv ) { QApplication application(argc,argv); Point p1( 0, 0, 0 ); Point p2( 5, 5 ,5 ); Point p3( 2, 3, 4 ); Domain domain( p1, p2 ); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); viewer << domain; viewer << p1 << p2 << p3; viewer<< MyViewer::updateDisplay; return application.exec(); }
int main( int argc, char** argv ) { QApplication application(argc,argv); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); Point p1( -1, -1, -2 ); Point p2( 2, 2, 3 ); Domain domain( p1, p2 ); Point p3( 1, 1, 1 ); Point p4( 2, -1, 3 ); Point p5( -1, 2, 3 ); Point p6( 0, 0, 0 ); Point p0( 0, 2, 1 ); viewer << SetMode3D( p1.className(), "PavingWired" ); viewer << p1 << p2 << p3; //viewer << SetMode3D( p1.className(), "Grid" ); viewer << CustomColors3D(Color(250, 0,0),Color(250, 0,0)); viewer << p4 << p5 ; viewer << SetMode3D( p1.className(), "Both" ); viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 0,0, 100)); viewer << p6; viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 200,0, 20)); viewer << p0; viewer << SetMode3D(domain.className(), "Paving"); viewer << domain << MyViewer::updateDisplay; return application.exec(); }
int main( int argc, char** argv ) { //! [ExampleViewer3DSets] QApplication application(argc,argv); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); Point p1( 0, 0, 0 ); Point p2( 10, 10 , 10 ); Domain domain( p1, p2 ); viewer << domain; DigitalSet shape_set( domain ); Shapes<Domain>::addNorm1Ball( shape_set, Point( 5, 5, 5 ), 2 ); Shapes<Domain>::addNorm2Ball( shape_set, Point( 3, 3, 3 ), 2 ); shape_set.erase(Point(3,3,3)); shape_set.erase(Point(6,6,6)); viewer << shape_set << MyViewer::updateDisplay; //! [ExampleViewer3DSets] return application.exec(); }
int main( int argc, char** argv ) { using namespace Z3i; QApplication application(argc,argv); trace.beginBlock ( "Testing class ChordNaivePlaneComputer" ); unsigned int nbok = 0; unsigned int nb = 0; typedef ChordNaivePlaneComputer<Z3, Z3::Point, int> PlaneComputer; typedef PlaneComputer::Primitive Primitive; PlaneComputer plane; plane.init( 2, 1, 1 ); Point pt0( 0, 0, 0 ); bool pt0_inside = plane.extend( pt0 ); trace.info() << "(" << nbok << "/" << nb << ") Plane=" << plane << std::endl; Point pt1( 8, 1, 3 ); bool pt1_inside = plane.extend( pt1 ); ++nb, nbok += pt1_inside == true ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt1 << " Plane=" << plane << std::endl; Point pt2( 2, 7, 1 ); bool pt2_inside = plane.extend( pt2 ); ++nb, nbok += pt2_inside == true ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt2 << " Plane=" << plane << std::endl; Point pt3( 0, 5, 12 ); bool pt3_inside = plane.extend( pt3 ); ++nb, nbok += pt3_inside == false ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt3 << " Plane=" << plane << std::endl; Point pt4( -5, -5, 10 ); bool pt4_inside = plane.extend( pt4 ); ++nb, nbok += pt4_inside == false ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt4 << " Plane=" << plane << std::endl; Point pt5 = pt0 + pt1 + pt2 + Point( 0, 0, 1 ); bool pt5_inside = plane.extend( pt5 ); ++nb, nbok += pt5_inside == true ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt5 << " Plane=" << plane << std::endl; Point pt6 = Point( 1, 0, 1 ); bool pt6_inside = plane.extend( pt6 ); ++nb, nbok += pt6_inside == true ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") add " << pt5 << " Plane=" << plane << std::endl; Primitive strip = plane.primitive(); trace.info() << "strip=" << strip << " axis=" << strip.mainAxis() << " axiswidth=" << strip.axisWidth() << " diag=" << strip.mainDiagonal() << " diagwidth=" << strip.diagonalWidth() << std::endl; ++nb, nbok += strip.axisWidth() < 1.0 ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") axiswidth < 1 " << std::endl; ++nb, nbok += strip.diagonalWidth() < sqrt(3.0) ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") axiswidth < sqrt(3) " << std::endl; trace.emphase() << ( nbok == nb ? "Passed." : "Error." ) << endl; trace.endBlock(); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); Color red( 255, 0, 0 ); Color green( 0, 255, 0 ); Color grey( 200, 200, 200 ); Domain domain( Point( -5, -5, -5 ), Point( 12, 12, 12 ) ); viewer << ( pt0_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt0; viewer << ( pt1_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt1; viewer << ( pt2_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt2; viewer << ( pt3_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt3; viewer << ( pt4_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt4; viewer << ( pt5_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt5; viewer << ( pt6_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt6; viewer << CustomColors3D( grey, grey ); displayPredicate( viewer, domain, plane ); viewer << MyViewer::updateDisplay; return application.exec(); }
int main( int argc, char** argv ) { typedef DGtal::ImageContainerBySTLVector<DGtal::Z3i::Domain, unsigned char > Image3D; QApplication application(argc,argv); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); std::string inputFilename = examplesPath + "samples/lobster.vol"; Image3D imageVol = VolReader<Image3D>::importVol(inputFilename); //! [ExampleViewer3D2DImagesExtractImages] // Extracting the 2D images from the 3D one and from a given dimension. // First image the teenth Z slice (dim=2) typedef DGtal::ConstImageAdapter<Image3D, DGtal::Z2i::Domain, DGtal::functors::Projector< DGtal::Z3i::Space>, Image3D::Value, DGtal::functors::Identity > MySliceImageAdapter; // Define the functor to recover a 2D domain from the 3D one in the Z direction (2): DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorZ; transTo2DdomainFunctorZ.initRemoveOneDim(2); DGtal::Z2i::Domain domain2DZ(transTo2DdomainFunctorZ(imageVol.domain().lowerBound()), transTo2DdomainFunctorZ(imageVol.domain().upperBound())); // Define the functor to associate 2D coordinates to the 3D one by giving the direction Z (2) and the slide numnber (10): DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorZ(10); aSliceFunctorZ.initAddOneDim(2); // We can now obtain the slice image (a ConstImageAdapter): const auto identityFunctor = DGtal::functors::Identity(); MySliceImageAdapter aSliceImageZ(imageVol, domain2DZ, aSliceFunctorZ, identityFunctor ); // Second image the fiftieth Y slice (dim=1) // Define the functor to recover a 2D domain from the 3D one in the Y direction (1): DGtal::functors::Projector<DGtal::Z2i::Space> transTo2DdomainFunctorY; transTo2DdomainFunctorY.initRemoveOneDim(1); DGtal::Z2i::Domain domain2DY(transTo2DdomainFunctorY(imageVol.domain().lowerBound()), transTo2DdomainFunctorY(imageVol.domain().upperBound())); // Define the functor to associate 2D coordinates to the 3D one by giving the direction Y (1) and the slide numnber (50): DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorY(50); aSliceFunctorY.initAddOneDim(1); // We can now obtain the slice image (a ConstImageAdapter): MySliceImageAdapter aSliceImageY(imageVol, domain2DY, aSliceFunctorY, identityFunctor ); //! [ExampleViewer3D2DImagesExtractImages] //! [ExampleViewer3D2DChangeMode] viewer << SetMode3D(aSliceImageZ.className(), "BoundingBox"); viewer << MyViewer::updateDisplay; //! [ExampleViewer3D2DChangeMode] //! [ExampleViewer3D2DImagesDisplayImages] viewer << aSliceImageZ; viewer << aSliceImageY; //! [ExampleViewer3D2DImagesDisplayImages] viewer << SetMode3D(aSliceImageZ.className(), ""); //! [ExampleViewer3D2DImagesDisplayImagesColor] viewer << AddTextureImage2DWithFunctor<MySliceImageAdapter, hueFct, Z3i::Space, Z3i::KSpace> (aSliceImageZ, hueFct(), Viewer3D<Z3i::Space, Z3i::KSpace>::RGBMode); viewer << AddTextureImage2DWithFunctor<MySliceImageAdapter, hueFct, Z3i::Space, Z3i::KSpace> (aSliceImageY, hueFct(), Viewer3D<Z3i::Space, Z3i::KSpace>::RGBMode); //! [ExampleViewer3D2DImagesDisplayImagesColor] //! [ExampleViewer3D2DModifImages] viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(1, MyViewer::yDirection, 0.0, 50.0, 0.0); viewer << DGtal::UpdateImageData<MySliceImageAdapter>(0, aSliceImageZ, 0, 0, 10); viewer << MyViewer::updateDisplay; //! [ExampleViewer3D2DModifImages] //! [ExampleViewer3D2DModifImagesColor] viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(3, MyViewer::yDirection, 500.0, 50.0, 0.0); viewer << DGtal::UpdateImageData<MySliceImageAdapter, hueFct>(2, aSliceImageZ, 500, 0, 10, 0.0, MyViewer::zDirection, hueFct()); viewer << MyViewer::updateDisplay; //! [ExampleViewer3D2DModifImagesColor] return application.exec(); trace.endBlock(); return 0; }
int main( int argc, char** argv ) { using namespace Z3i; unsigned int nb = 0; unsigned int nbok = 0; QApplication application(argc,argv); unsigned int diameter = argc > 1 ? atoi( argv[ 1 ] ) : 10; int a = argc > 2 ? atoi( argv[ 2 ] ) : 2; int b = argc > 3 ? atoi( argv[ 3 ] ) : 3; int c = argc > 4 ? atoi( argv[ 4 ] ) : 5; int mu = argc > 5 ? atoi( argv[ 5 ] ) : 0; trace.beginBlock ( "Testing class ChordGenericStandardPlaneComputer" ); trace.info() << "Recognizing plane " << mu << " <= " << a << " * x + " << b << " * y + " << c << " * z < " << (mu+abs(a)+abs(b)+abs(c)) << std::endl; Domain domain1( Point( -diameter, -diameter, -diameter ), Point( diameter, diameter, diameter ) ); typedef int64_t Integer; typedef ChordGenericStandardPlaneComputer<Z3, Point, Integer> PlaneComputer; typedef PlaneComputer::Primitive Primitive; PlaneComputer plane; plane.init( 1, 1 ); std::vector<Point> recognized = pointsInStandardPlane( domain1, a, b , c, mu ); ++nb, nbok += plane.extend( recognized.begin(), recognized.end() ) ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") All points are recognized." << std::endl; trace.info() << " - Plane=" << plane << std::endl; Primitive strip = plane.primitive(); trace.info() << "strip=" << strip << " axis=" << strip.mainAxis() << " axiswidth=" << strip.axisWidth() << " diag=" << strip.mainDiagonal() << " diagwidth=" << strip.diagonalWidth() << std::endl; ++nb, nbok += ( strip.diagonalWidth() < sqrt(3.0) ) ? 1 : 0; trace.info() << "(" << nbok << "/" << nb << ") Diagonal width < sqrt(3)." << std::endl; trace.emphase() << ( (nb == nbok) ? "Passed." : "Error." ) << endl; trace.endBlock(); typedef Viewer3D<> MyViewer; MyViewer viewer; viewer.show(); Color red( 255, 0, 0 ); Color green( 0, 255, 0 ); Color grey( 200, 200, 200 ); Domain domain2( Point( -2*diameter, -2*diameter, -2*diameter ), Point( 2*diameter, 2*diameter, 2*diameter ) ); viewer << CustomColors3D( red, red ); for ( std::vector<Point>::const_iterator it = recognized.begin(), itE = recognized.end(); it != itE; ++it ) if ( ! strip( *it ) ) viewer << *it; viewer << CustomColors3D( green, green ); displayRange( viewer, plane.begin(), plane.end() ); viewer << CustomColors3D( grey, grey ); displayPredicate( viewer, domain2, strip ); viewer << MyViewer::updateDisplay; trace.info() << "- Points in green have been recognized as belonging to this standard plane." << std::endl; trace.info() << "- Points in grey belongs also to the parallel strip of the recognized standard plane." << std::endl; trace.info() << "- Points in red belongs to the parallel strip of the recognized standard plane but not to the input standard plane: NONE should be red." << std::endl; return application.exec(); }