31 #include "DGtal/base/Common.h"
32 #include "DGtal/base/BasicFunctors.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/io/readers/GenericReader.h"
35 #include "DGtal/io/Color.h"
36 #include "DGtal/io/DrawWithDisplay3DModifier.h"
39 #include "sliceViewer.h"
40 #include "ui_sliceViewer.h"
44 #include "DGtal/io/viewers/Viewer3D.h"
45 #include "DGtal/io/viewers/DrawWithViewer3DModifier.h"
46 #include "DGtal/io/readers/PointListReader.h"
47 #include "DGtal/images/ConstImageAdapter.h"
48 #include <boost/program_options/options_description.hpp>
49 #include <boost/program_options/parsers.hpp>
50 #include <boost/program_options/variables_map.hpp>
54 using namespace DGtal;
58 namespace po = boost::program_options;
105 static const int MIN_ZOOM_FACTOR = 10.0;
106 static const int MAX_ZOOM_FACTOR = 40.0;
107 static const int INIT_SCALE1_ZOOM_FACTOR = 20.0;
111 template <
typename TImage>
119 std::vector<double> scales;
120 scales.push_back(gridSize);
121 scales.push_back(gridSize);
125 ConstImageAdapterForSubSampling scaledImage (anImage, newDomain, subSampler, colFunctor );
126 unsigned int height = scaledImage.domain().upperBound()[1]-scaledImage.domain().lowerBound()[1];
127 unsigned int width = scaledImage.domain().upperBound()[0]-scaledImage.domain().lowerBound()[0];
128 QImage res (width, height,QImage::Format_RGB32 );
129 for(
unsigned int i=0; i<height; i++){
130 for(
unsigned int j=0; j<width; j++){
131 res.setPixel(j, height-i-1, scaledImage(
Z2i::Point(j,i)+scaledImage.domain().lowerBound()));
140 const ColorMapFunctor &aFunctor, QWidget *parent, Qt::WindowFlags flags) :
149 ui->verticalLayout_5->addWidget(aViewer);
164 ui->_zoomXSlider->setMinimum( MIN_ZOOM_FACTOR);
165 ui->_zoomXSlider->setMaximum( MAX_ZOOM_FACTOR);
166 ui->_zoomXSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
168 ui->_zoomYSlider->setMinimum(MIN_ZOOM_FACTOR);
169 ui->_zoomYSlider->setMaximum(MAX_ZOOM_FACTOR);
170 ui->_zoomYSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
172 ui->_zoomZSlider->setMinimum(MIN_ZOOM_FACTOR);
173 ui->_zoomZSlider->setMaximum(MAX_ZOOM_FACTOR);
174 ui->_zoomZSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
176 QObject::connect(
ui->_horizontalSliderX, SIGNAL(valueChanged(
int)),
this, SLOT(
updateSliceImageX()));
177 QObject::connect(
ui->_horizontalSliderY, SIGNAL(valueChanged(
int)),
this, SLOT(
updateSliceImageY()));
178 QObject::connect(
ui->_horizontalSliderZ, SIGNAL(valueChanged(
int)),
this, SLOT(
updateSliceImageZ()));
179 QObject::connect(
ui->_zoomXSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
updateZoomImageX()));
180 QObject::connect(
ui->_zoomYSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
updateZoomImageY()));
181 QObject::connect(
ui->_zoomZSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
updateZoomImageZ()));
225 ui->ImageProjX->setPixmap(aPixMap);
228 ui->ImageProjY->setPixmap(aPixMap);
231 ui->ImageProjZ->setPixmap(aPixMap);
249 ui->_zoomXSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
254 ui->_zoomYSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
259 ui->_zoomZSlider->setValue(INIT_SCALE1_ZOOM_FACTOR);
266 double gridSize = (double)INIT_SCALE1_ZOOM_FACTOR/
ui->_zoomXSlider->value();
268 QString gridStr = QString::number(gridSize,
'f', 3);
269 QString scaleStr = QString::number(1.0/gridSize,
'f', 3);
270 ui->_groupBoxX->setTitle(QString(
"Slice View X: sampling grid size: ").append(gridStr).
271 append(QString(
" (zoom x "). append(scaleStr).append(QString(
")") )));
274 double gridSize = (double)INIT_SCALE1_ZOOM_FACTOR/
ui->_zoomYSlider->value();
276 QString gridStr = QString::number(gridSize,
'f', 3);
277 QString scaleStr = QString::number(1.0/gridSize,
'f', 3);
278 ui->_groupBoxY->setTitle(QString(
"Slice View Y: sampling grid size: ").append(gridStr).
279 append(QString(
" (zoom x "). append(scaleStr).append(QString(
")") )));
283 double gridSize = (double)INIT_SCALE1_ZOOM_FACTOR/
ui->_zoomZSlider->value();
285 QString gridStr = QString::number(gridSize,
'f', 3);
286 QString scaleStr = QString::number(1.0/gridSize,
'f', 3);
287 ui->_groupBoxZ->setTitle(QString(
"Slice View Z: sampling grid size: ").append(gridStr).
288 append(QString(
" (zoom x "). append(scaleStr).append(QString(
")") )));
300 QImage anImage = getImage(sliceImage, gridSize,
myColorMap);
312 QImage anImage = getImage(sliceImage, gridSize,
myColorMap);
324 QImage anImage = getImage(sliceImage, gridSize,
myColorMap );
337 double gridSize = ((double)INIT_SCALE1_ZOOM_FACTOR)/
ui->_zoomXSlider->value();
338 QImage anImage = getImage(sliceImage, gridSize,
myColorMap);
344 imageOrigin[1], imageOrigin[2]);
351 (*myViewer).updateList(init);
352 (*myViewer).update();
368 double gridSize = ((double)INIT_SCALE1_ZOOM_FACTOR)/
ui->_zoomYSlider->value();
369 QImage anImage = getImage(sliceImage, gridSize,
myColorMap);
375 sliceNumber, imageOrigin[2]);
380 sliceNumber, imageOrigin[2]);
381 (*myViewer).updateList(init);
382 (*myViewer).update();
396 double gridSize = (double)INIT_SCALE1_ZOOM_FACTOR/
ui->_zoomZSlider->value();
397 QImage anImage = getImage(sliceImage, gridSize,
myColorMap);
403 imageOrigin[1], sliceNumber);
410 imageOrigin[1], sliceNumber);
411 (*myViewer).updateList(init);
412 (*myViewer).update();
420 int main(
int argc,
char** argv )
423 po::options_description general_opt(
"Allowed options are: ");
424 general_opt.add_options()
425 (
"help,h",
"display this message")
426 (
"input,i", po::value<std::string>(),
"vol file (.vol, .longvol .p3d, .pgm3d and if WITH_ITK is selected: dicom, dcm, mha, mhd). For longvol, dicom, dcm, mha or mhd formats, the input values are linearly scaled between 0 and 255." )
427 (
"hueColorMap",
"use hue color map to display images." )
428 (
"gradHotColorMap",
"use hot gradient color map to display images." )
429 (
"gradCoolColorMap",
"use cool gradient color map to display images." )
430 (
"rescaleInputMin", po::value<DGtal::int64_t>()->default_value(0),
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image).")
431 (
"rescaleInputMax", po::value<DGtal::int64_t>()->default_value(255),
"max value used to rescale the input intensity (to avoid basic cast into 8 bits image).");
434 po::variables_map vm;
436 po::store(po::parse_command_line(argc, argv, general_opt), vm);
437 }
catch(
const std::exception& ex){
439 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
442 if( !parseOK || vm.count(
"help")||argc<=1)
444 std::cout <<
"Usage: " << argv[0] <<
" [input]\n"
445 <<
"Displays volume file with slice image by using QT and QGLviewer"<< endl
446 << general_opt <<
"\n";
450 if(! vm.count(
"input"))
452 trace.
error() <<
" The file name was defined" << endl;
455 string inputFilename = vm[
"input"].as<std::string>();
468 trace.
info() <<
"Imported..."<< std::endl;
474 QApplication application(argc,argv);
476 bool usehm = vm.count(
"hueColorMap");
477 bool usegh = vm.count(
"gradHotColorMap");
478 bool usegc = vm.count(
"gradCoolColorMap");
484 w.setWindowTitle ( QString(
"sliceViewer"));
485 w.updateSliceImageX( image.
domain().lowerBound()[0],
true);
486 w.updateSliceImageY( image.
domain().lowerBound()[1],
true);
487 w.updateSliceImageZ( image.
domain().lowerBound()[2],
true);
491 unsigned int maxDist = std::max(std::max(size[2], size[1]), size[2]);
492 viewer->camera()->setPosition(qglviewer::Vec(center[0],center[1],
493 center[2] + 2.0*maxDist));
494 viewer->camera()->setSceneCenter(qglviewer::Vec(center[0],center[1],center[2]));
void setScale1_1_ImageY()
void changeNormalColorMap()
MainWindow(DGtal::Viewer3D<> *viewer, DGtal::ImageContainerBySTLVector< DGtal::Z3i::Domain, unsigned char > *myImage3D, const ColorMapFunctor &aFunctor, QWidget *parent=0, Qt::WindowFlags flags=0)
void initRemoveOneDim(const Dimension &dimRemoved)
const TDomain & getSubSampledDomain()
void changeCoolColorMap()
ColorMapFunctor myColorMap
void setScale1_1_ImageZ()
void setImageProjY(const QPixmap &aPixMap)
const Point & upperBound() const
void setImageProjZ(const QPixmap &aPixMap)
Trace trace(traceWriterTerm)
void initAddOneDim(const Dimension &newDim)
const Domain & domain() const
void updateAllDisplayedImages()
void setScale1_1_ImageX()
const Point & lowerBound() const
void setImageProjX(const QPixmap &aPixMap)