initial commit
This commit is contained in:
commit
53a50c61af
30
Build/.qglviewer.xml
Normal file
30
Build/.qglviewer.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE QGLVIEWER>
|
||||
<QGLViewer version="2.6.3">
|
||||
<State stereo="false">
|
||||
<foregroundColor blue="25" red="217" green="22"/>
|
||||
<backgroundColor blue="255" red="217" green="228"/>
|
||||
</State>
|
||||
<Display FPSIsDisplayed="false" gridIsDrawn="false" axisIsDrawn="false" cameraIsEdited="false"/>
|
||||
<Geometry width="800" fullScreen="false" posX="100" posY="127" height="600"/>
|
||||
<Camera>
|
||||
<Parameters zClippingCoefficient="1.73205" Type="PERSPECTIVE" fieldOfView="0.785398" sceneRadius="22.4054" zNearCoefficient="0.005" orthoCoef="0.670991">
|
||||
<SceneCenter y="1" x="1" z="1"/>
|
||||
</Parameters>
|
||||
<Stereo physScreenWidth="0.5" focusDistance="54.0913" IODist="0.062"/>
|
||||
<ManipulatedCameraFrame>
|
||||
<position y="-36.9988" x="45.4908" z="-1.12818"/>
|
||||
<orientation q2="0.174868" q1="0.411944" q0="0.590319" q3="0.671749"/>
|
||||
<ManipulatedParameters zoomSens="1" rotSens="1" transSens="1" spinSens="0.3" wheelSens="1"/>
|
||||
<ManipulatedCameraParameters rotatesAroundUpVector="false" flySpeed="0.224054" zoomsOnPivotPoint="false">
|
||||
<sceneUpVector y="1" x="0" z="0"/>
|
||||
</ManipulatedCameraParameters>
|
||||
</ManipulatedCameraFrame>
|
||||
</Camera>
|
||||
<ManipulatedFrame>
|
||||
<position y="0" x="0" z="0"/>
|
||||
<orientation q2="0" q1="0" q0="0" q3="1"/>
|
||||
<ManipulatedParameters zoomSens="1" rotSens="1" transSens="1" spinSens="0.3" wheelSens="1"/>
|
||||
</ManipulatedFrame>
|
||||
<Light pos_light_y="-84.9391" pos_light_x="10.6884" pos_light_z="127.287"/>
|
||||
<Rendering mode="0"/>
|
||||
</QGLViewer>
|
30
CMakeLists.txt
Normal file
30
CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(startCode)
|
||||
|
||||
set(as_subproject QGLVIEWER)
|
||||
macro(find_package)
|
||||
if(NOT "${ARGV0}" IN_LIST as_subproject)
|
||||
_find_package(${ARGV})
|
||||
else()
|
||||
set(${ARGV0}_FOUND true)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
add_subdirectory(external/libQGLViewer)
|
||||
add_subdirectory(external/DGtal)
|
||||
|
||||
# Make sure the compiler can find include files.
|
||||
include_directories(${PROJECT_SOURCE_DIR}/Volumes/)
|
||||
include_directories(${PROJECT_BINARY_DIR}/Volumes/)
|
||||
|
||||
# ConfigExamples.h instanciation.
|
||||
configure_file(${PROJECT_SOURCE_DIR}/ConfigExamples.h.in
|
||||
${PROJECT_SOURCE_DIR}/ConfigExamples.h)
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets)
|
||||
add_executable(startCode startCode.cpp)
|
||||
target_link_libraries(startCode PRIVATE libQGLViewer DGtal Qt5::Widgets)
|
||||
target_compile_definitions(startCode PRIVATE
|
||||
WITH_QT5 true
|
||||
WITH_VISU3D_QGLVIEWER true)
|
13
ConfigExamples.h
Normal file
13
ConfigExamples.h
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @file ConfigExamples.h
|
||||
* @author David COEURJOLLY <David Coeurjolly <david.coeurjolly@liris.cnrs.fr>>
|
||||
* @date 29 Jul. 2010
|
||||
* @brief Configuration header for example files.
|
||||
*
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
|
||||
///Path to the DGtal test suite.
|
||||
const std::string examplesPath= "/home/papush/m2b/géo_dis/tp10/startCode_1.10/Volumes/";
|
||||
|
13
ConfigExamples.h.in
Normal file
13
ConfigExamples.h.in
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @file ConfigExamples.h
|
||||
* @author David COEURJOLLY <David Coeurjolly <david.coeurjolly@liris.cnrs.fr>>
|
||||
* @date 29 Jul. 2010
|
||||
* @brief Configuration header for example files.
|
||||
*
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
|
||||
///Path to the DGtal test suite.
|
||||
const std::string examplesPath= "@PROJECT_SOURCE_DIR@/Volumes/";
|
||||
|
BIN
Volumes/Al.100.vol
Normal file
BIN
Volumes/Al.100.vol
Normal file
Binary file not shown.
16
Volumes/cat10.vol
Normal file
16
Volumes/cat10.vol
Normal file
@ -0,0 +1,16 @@
|
||||
Center-X: 0
|
||||
Center-Y: 0
|
||||
Center-Z: 0
|
||||
X: 40
|
||||
Y: 40
|
||||
Z: 40
|
||||
Voxel-Size: 1
|
||||
Alpha-Color: 0
|
||||
Voxel-Endian: 0
|
||||
Int-Endian: 0123
|
||||
Version: 3
|
||||
.
|
||||
xœíÚQn¬0DQ/•ý¯â)ÒS"ÜÕPöÀ`›{¿ÏO„Û-”BDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDû¶Ÿ,´<>ÑmŸÉ2˜†‚)(Y„ Ðt)«àÅî€íàÛܼõ¹å°ô¹ÖÌž{ÞìùµïƒâÞ/ôÑpyÏÍ;Þ±ê=Îí×I& é6ÙÞÞå°óyd°f¶Ó02Û)¨XÃ^(žÚÉCõ+O^ÃiñOß±4<C2B1>}ï±<>Öq¬™í4ŒÌv
|
||||
*vÇ{€É
|
||||
{<7B>ž®áôù§¹a<¾µg\'Ø@ûh§ad¶SP1ÛE¨{<7B>è,ï8›ãÑ3n‹ï\âTÌvjvÇ^0Yqç<71>h–¬ÓlŽGû¸M»g\'ØP÷¸ëÜ¿÷r¡f<C2A1>î“ý§çˆh©Ìñðæ¨gÌý˜l°=ó:¡f—Ÿƒ[þßd2¢wæ<77>‡9oæøö\ï×6Øýü”‹P3ÛÕ0cϾWxŠèm²Æ}ÌÇ{O¹Ú6ë}ïºfÌvÅd7}¯°å5Meد¿?\Øh{Áu5̘íŠÉøÞMôõ6µLeد¿?ãý£Ñ“ñþAôå¼12Dz}Ìùþ1‹‹P3ÛÕ0c|ÿ 4sŒ¼yë¹øýÕb.BÍøýѸY§Þœ#s,{Æ|Ö½ ˜„£;÷ï½ÜE¨Ù$ï)ÅBDSäûöq›v/6Ô=¾ŠSP1ÛE¨Ù4ßSˆžË;¦Þ±ï·Å÷‚d¾Íi™íTÌvjöìÿʧˆÚj8}þin<18>oíÁºïàÛ\kf;
#³<>‚Š±gh¦N‹úeïqß笂os9ì|¬™í4ŒÌv
|
||||
*Ö°<C396>Š§vòPýÊSE£e=7︘ǯ÷8´$[õ?`;ø6wo}n9,}.ƒ5›ã½§xê<78>ž!""""""""""""""""""""""""""""""¢!û!ÈÆ
|
BIN
Volumes/lobster.vol
Normal file
BIN
Volumes/lobster.vol
Normal file
Binary file not shown.
15
external/DGtal/CMakeLists.txt
vendored
Normal file
15
external/DGtal/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
set(WITH_QGLVIEWER true)
|
||||
set(WITH_QT5 true)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
|
||||
FetchContent_Declare(
|
||||
DGtal
|
||||
URL https://github.com/DGtal-team/DGtal/archive/refs/tags/1.2.tar.gz
|
||||
URL_HASH MD5=19e443ca4f3927c9b9eff742cdfa138f
|
||||
DEPENDS libQGLViewer_ep-build)
|
||||
|
||||
FetchContent_MakeAvailable(DGtal)
|
41
external/libQGLViewer/CMakeLists.txt
vendored
Normal file
41
external/libQGLViewer/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
libQGLViewer
|
||||
URL http://www.libqglviewer.com/src/libQGLViewer-2.7.2.tar.gz
|
||||
URL_HASH MD5=a9d965d1ce41f7db6b34f440bb74f061
|
||||
CONFIGURE_COMMAND "qmake ${CMAKE_CURRENT_SOURCE_DIR}/QGLViewer/QGLViewer.pro"
|
||||
STEP_TARGETS build
|
||||
# BUILD_BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/QGLViewer/libQGLViewer-qt5.so
|
||||
LOG_DOWNLOAD true
|
||||
LOG_CONFIGURE true
|
||||
LOG_BUILD true
|
||||
LOG_INSTALL true)
|
||||
|
||||
ExternalProject_Get_property(libQGLViewer_ep SOURCE_DIR)
|
||||
message("libqglviewer_ep src dir: ${SOURCE_DIR}")
|
||||
ExternalProject_Get_property(libQGLViewer_ep CONFIGURE_COMMAND)
|
||||
message("libqglviewer_ep configure command: ${CONFIGURE_COMMAND}")
|
||||
# ExternalProject_Get_property(libQGLViewer_ep BUILD_BYPRODUCTS)
|
||||
# message("libqglviewer_ep build byproducts: ${BUILD_BYPRODUCTS}")
|
||||
|
||||
set(QGLVIEWER_INCLUDE_DIR
|
||||
$<BUILD_INTERFACE:${SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
CACHE PATH "")
|
||||
# # Can't use find_library as the library isn't there at config time
|
||||
# find_library(QGLVIEWER_LIBRARIES
|
||||
# NAMES qglviewer-qt4 qglviewer QGLViewer QGLViewer2 QGLViewer-qt5
|
||||
# PATHS ${SOURCE_DIR}
|
||||
# PATH_SUFFIXES QGLViewer QGLViewer/release)
|
||||
set(QGLVIEWER_LIBRARIES
|
||||
$<BUILD_INTERFACE:${SOURCE_DIR}/QGLViewer/libQGLViewer-qt5.so>
|
||||
$<INSTALL_INTERFACE:lib/libQGLViewer-qt5.so>
|
||||
CACHE FILEPATH "")
|
||||
|
||||
add_library(libQGLViewer INTERFACE)
|
||||
target_link_libraries(libQGLViewer INTERFACE ${QGLVIEWER_LIBRARIES})
|
||||
add_dependencies(libQGLViewer libQGLViewer_ep-build)
|
||||
target_include_directories(libQGLViewer INTERFACE ${QGLVIEWER_INCLUDE_DIR})
|
251
startCode.cpp
Normal file
251
startCode.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
#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>
|
||||
|
||||
#include <DGtal/kernel/SpaceND.h>
|
||||
#include <DGtal/kernel/domains/HyperRectDomain.h>
|
||||
#include <DGtal/images/ImageSelector.h>
|
||||
|
||||
#include <DGtal/geometry/volumes/distance/DistanceTransformation.h>
|
||||
#include <DGtal/images/SimpleThresholdForegroundPredicate.h>
|
||||
#include <DGtal/helpers/StdDefs.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace std;
|
||||
using namespace DGtal;
|
||||
|
||||
|
||||
|
||||
struct hueFct{
|
||||
inline
|
||||
unsigned int operator() (unsigned int aVal) const
|
||||
{
|
||||
HueShadeColorMap<unsigned int> hueShade(0,255);
|
||||
Color col = hueShade((unsigned int)aVal);
|
||||
return (((unsigned int) col.red()) << 16)| (((unsigned int) col.green()) << 8)|((unsigned int) col.blue());
|
||||
}
|
||||
};
|
||||
|
||||
// Définition du type de viewer à utiliser.
|
||||
typedef Viewer3D<> ViewerType ;
|
||||
// Définition du type de conteneur à utiliser pour l'image du premier exercice.
|
||||
typedef ImageContainerBySTLVector<Z3i::Domain, float> Image3D;
|
||||
// Définition du type de conteneur à utiliser pour l'image de la transformée en distance.
|
||||
typedef ImageSelector<Z3i::Domain, unsigned char>::Type Image;
|
||||
|
||||
// Parcours et traitement d'un volume.
|
||||
void imageSandbox(ViewerType& viewer, std::string filename);
|
||||
// Tranformée en distance.
|
||||
void transformeeEnDistance(ViewerType& viewer, std::string filename);
|
||||
|
||||
// Méthode pour générer des voxels de manière aléatoire.
|
||||
template<typename Image>
|
||||
void randomSeeds(Image &image, const unsigned int nb, const int value);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
QApplication application(argc,argv);
|
||||
ViewerType viewer;
|
||||
|
||||
// Appel aux méthodes des exercices.
|
||||
if (argc > 2)
|
||||
{
|
||||
std::stringstream ssAlgo;
|
||||
ssAlgo << std::string(argv[1]);
|
||||
|
||||
std::stringstream ssFile;
|
||||
ssFile << std::string(argv[2]);
|
||||
if (ssAlgo.str() == "Sandbox")
|
||||
imageSandbox(viewer, ssFile.str());
|
||||
else if (ssAlgo.str() == "DT")
|
||||
transformeeEnDistance(viewer, ssFile.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Les paramètres n'a pas été fourni." << std::endl;
|
||||
std::cout << "startCode <paramètre = {Sandbox | DT}> <nom du fichier>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return application.exec();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cette fonction vous permettra de commencer à pratiquer avec le chargement d'objets
|
||||
* volumiques. Les parcourir, retrouver les valeurs affectées à chaque voxel et les
|
||||
* les modifier.
|
||||
* \param Visualisateur à utiliser.
|
||||
* \param Nom du fichier.
|
||||
*
|
||||
*/
|
||||
void imageSandbox(ViewerType& viewer, std::string filename)
|
||||
{
|
||||
// Lance le visusalisateur.
|
||||
viewer.show();
|
||||
|
||||
//Chargement d'une image dans une structure de données ImageContainerBySTLVector.
|
||||
std::string inputFilename = examplesPath + "/" + filename;
|
||||
Image3D image = GenericReader<Image3D>::import(inputFilename);
|
||||
|
||||
// Obtention du domaine (taille) de l'image chargée.
|
||||
Z3i::Domain initialDomain = image.domain();
|
||||
|
||||
// Définition du gradient des couleurs.
|
||||
GradientColorMap<long> gradient( 0,30);
|
||||
gradient.addColor(Color::Red);
|
||||
gradient.addColor(Color::Yellow);
|
||||
gradient.addColor(Color::Green);
|
||||
gradient.addColor(Color::Cyan);
|
||||
gradient.addColor(Color::Blue);
|
||||
gradient.addColor(Color::Magenta);
|
||||
gradient.addColor(Color::Red);
|
||||
|
||||
float min = 0.0;
|
||||
float max = 0.0;
|
||||
|
||||
for(Z3i::Domain::ConstIterator it= image.domain().begin(),
|
||||
itend = image.domain().end(); it != itend; ++it)
|
||||
{
|
||||
if (image(*it) > 0)
|
||||
viewer << *it;
|
||||
}
|
||||
|
||||
viewer << SetMode3D(image.className(), "BoundingBox");
|
||||
viewer << ViewerType::updateDisplay;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de la transformée en distance à partir de quelques points germes.
|
||||
* La distance est calculée à partir de chaque point. Donc, la distance dans un
|
||||
* voxel est la distance minimale à tous les points germes.
|
||||
* \param le visualisateur à utiliser.
|
||||
* \param Nom du fichier.
|
||||
*
|
||||
*/
|
||||
void transformeeEnDistance(ViewerType& viewer, std::string filename)
|
||||
{
|
||||
// Affichage de la visualisation.
|
||||
viewer.show();
|
||||
// Nombre du fichier à charger.
|
||||
std::string inputFilename = examplesPath + "/" + filename;
|
||||
|
||||
// Création du type d'image.
|
||||
//Default image selector = STLVector
|
||||
typedef ImageSelector<Z3i::Domain, unsigned char>::Type Image;
|
||||
|
||||
//Chargement du fichier image dans la structure.
|
||||
Image image = VolReader<Image>::importVol( inputFilename );
|
||||
// Obtention du domaine (taille) de l'image.
|
||||
Z3i::Domain domain = image.domain();
|
||||
|
||||
Image imageSeeds ( domain);
|
||||
for ( Image::Iterator it = imageSeeds.begin(), itend = imageSeeds.end();it != itend; ++it)
|
||||
(*it)=1;
|
||||
//imageSeeds.setValue(p0, 0 );
|
||||
randomSeeds(imageSeeds, 70, 0);
|
||||
|
||||
|
||||
typedef functors::SimpleThresholdForegroundPredicate<Image> Predicate;
|
||||
Predicate aPredicate(imageSeeds,0);
|
||||
|
||||
// Création de type et de l'objet pour appliquer la transformée.
|
||||
typedef DistanceTransformation<Z3i::Space,Predicate, Z3i::L2Metric> DTL2;
|
||||
DTL2 dtL2(&domain, &aPredicate, &Z3i::l2Metric);
|
||||
|
||||
// Detection des distances minimales et maximales.
|
||||
unsigned int min = 0;
|
||||
unsigned int max = 0;
|
||||
for(DTL2::ConstRange::ConstIterator it = dtL2.constRange().begin(),
|
||||
itend=dtL2.constRange().end();
|
||||
it!=itend;
|
||||
++it)
|
||||
{
|
||||
if( (*it) < min )
|
||||
min=(*it);
|
||||
if( (*it) > max )
|
||||
max=(*it);
|
||||
}
|
||||
|
||||
//Spécification des gradients de couleur pour la visualisation.
|
||||
GradientColorMap<long> gradient( 0,30);
|
||||
gradient.addColor(Color::Red);
|
||||
gradient.addColor(Color::Yellow);
|
||||
gradient.addColor(Color::Green);
|
||||
gradient.addColor(Color::Cyan);
|
||||
gradient.addColor(Color::Blue);
|
||||
gradient.addColor(Color::Magenta);
|
||||
gradient.addColor(Color::Red);
|
||||
|
||||
// Affectation du mode de visualisation 3D.
|
||||
viewer << SetMode3D( (*(domain.begin())).className(), "Paving" );
|
||||
|
||||
// Parcours de tous les voxels de l'image avec un iterateur sur le domaine.
|
||||
for(Z3i::Domain::ConstIterator it = domain.begin(), itend=domain.end();
|
||||
it!=itend;
|
||||
++it)
|
||||
{
|
||||
|
||||
// Calcul de la transformée en distance pour le voxel courant.
|
||||
double valDist= dtL2( (*it) );
|
||||
|
||||
// Calcul du gradient de couleur pour cette distance.
|
||||
Color c= gradient(valDist);
|
||||
viewer << CustomColors3D(Color((float)(c.red()),
|
||||
(float)(c.green()),
|
||||
(float)(c.blue(),205)),
|
||||
Color((float)(c.red()),
|
||||
(float)(c.green()),
|
||||
(float)(c.blue()),205));
|
||||
// Le viewer reçoit le prochain voxel pour visualisation.
|
||||
if (image(*it) > 0)
|
||||
viewer << *it ;
|
||||
}
|
||||
|
||||
//viewer << ClippingPlane(0,1,0, -40) << Viewer3D<>::updateDisplay;
|
||||
// Mise à jour du visualisateur après le parcours de tous le voxels.
|
||||
viewer<< Viewer3D<>::updateDisplay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cette fonction genère un ensemble de points afin de les placer
|
||||
* dans le volume comme les germes de la transformée en distance.
|
||||
* \param image.
|
||||
* \param nombre de germes.
|
||||
* \param value à affecter comme seuil.
|
||||
*
|
||||
*/
|
||||
template<typename Image>
|
||||
void randomSeeds(Image &image, const unsigned int nb, const int value)
|
||||
{
|
||||
typename Image::Point p, low = image.domain().lowerBound();
|
||||
typename Image::Vector ext;
|
||||
srand ( time(NULL) );
|
||||
|
||||
ext = image.extent();
|
||||
|
||||
for (unsigned int k = 0 ; k < nb; k++)
|
||||
{
|
||||
for (unsigned int dim = 0; dim < Image::dimension; dim++)
|
||||
p[dim] = rand() % (ext[dim]) + low[dim];
|
||||
|
||||
image.setValue(p, value);
|
||||
}
|
||||
}
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user