DGtal  1.3.beta
io/viewers/viewer3D-9-3Dimages.cpp
Illustration of the 3D image visualization.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/GenericReader.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/images/Image.h"
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/Color.h"
using namespace std;
using namespace DGtal;
struct hueFct{
inline
unsigned int operator() (unsigned int aVal) const
{
Color col = hueShade((unsigned int)aVal);
return (((unsigned int) col.red()) << 16)| (((unsigned int) col.green()) << 8)|((unsigned int) col.blue());
}
};
int main( int argc, char** argv )
{
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");
viewer << AddTextureImage3DWithFunctor<Image3D, hueFct, Z3i::Space, Z3i::KSpace> (imageCrop2, hueFct(), MyViewer::RGBMode);
return application.exec();
}
// //
DGtal::Viewer3D< Space, KSpace >::RGBMode
@ RGBMode
Definition: Viewer3D.h:476
DGtal::HyperRectDomain< Space >
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::HueShadeColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition: HueShadeColorMap.h:90
DGtal::Display3D::updateDisplay
@ updateDisplay
Definition: Display3D.h:249
DGtal::GenericReader
Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by pa...
Definition: GenericReader.h:101
DGtal::Color::red
void red(const unsigned char aRedValue)
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::SetMode3D
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Definition: DrawWithDisplay3DModifier.h:73
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Color::green
void green(const unsigned char aGreenValue)
DGtal::Color::blue
void blue(const unsigned char aBlueValue)
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
DGtal::PointVector< dim, Integer >
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...