<div dir="ltr">Based on ImageColorViewer of InsightApplications I adapted the code to visualice a dicom rgb serie with 2D slices. The code, named DicomSeriesColorViewer, looks like:<br><br>#include <iostream>
<br> <br>#include "itkImage.h"
<br>#include "itkRGBPixel.h"
<br>#include "itkImageSeriesReader.h"
<br>#include "itkGDCMImageIO.h"
<br>#include "itkGDCMSeriesFileNames.h"
<br>#include "itkNumericSeriesFileNames.h"<br>#include <vector><br>#include <itksys/SystemTools.hxx><br><br>#include "itkImageFileReader.h"
<br> <br>#include <FL/Fl.H>
<br>#include <FL/Fl_Window.H>
<br>#include <FL/fl_file_chooser.H>
<br>#include "GLColorSliceView.h"
<br>#include "GLSliceView.h"
<br>#include "SliceView.h"
<br> <br>#include "DicomSeriesColorViewerGUI.h"
<br> <br> <br>Fl_Window *form;
<br> <br>int usage(void)
<br> {
<br> std::cout << "DicomSeriesColorViewer" << std::endl;
<br> std::cout << std::endl;
<br> std::cout << "DicomSeriesColorViewer <DirName>" << std::endl;
<br> std::cout << std::endl;
<br> <br> return 1;
<br> }
<br> <br>int main(int argc, char **argv)
<br> {
<br> char *fName;
<br> <br> if(argc > 2)
<br> {
<br> return usage();
<br> }
<br> else
<br> if(argc == 1)
<br> {
<br> fName = fl_dir_chooser("Selecciona un directorio contenedor de la serie dicom", "", 0);
<br> if(fName == NULL || strlen(fName)<1)
<br> {
<br> return 0;
<br> }
<br> }
<br> else
<br> if(argv[1][0] != '-')
<br> {
<br> fName = argv[argc-1];
<br> }
<br> else
<br> {
<br> return usage();
<br> }
<br> <br> std::cout << "Cargando Serie Dicom: " << fName << std::endl;<br> typedef itk::RGBPixel< unsigned char> RGBPixelType;<br> typedef itk::Image< RGBPixelType, 3 > ImageSerieTypeRGB;
<br> typedef itk::ImageSeriesReader< ImageSerieTypeRGB > ReaderSerieType;
<br> ReaderSerieType::Pointer readerSerie = ReaderSerieType::New();
<br> typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();<br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br> NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>
namesGenerator->SetInputDirectory(fName);<br> const ReaderSerieType::FileNamesContainer & filenames = namesGenerator->GetInputFileNames();<br> readerSerie->SetImageIO( gdcmImageIO );
<br> readerSerie->SetFileNames(filenames);
<br>
<br> <br> try
<br> {
<br> readerSerie->Update();
<br> }
<br> <br> catch (itk::ExceptionObject & e)
<br> <br> {<br> std::cerr << "error";
<br> throw e;
<br> }
<br> <br> typedef itk::GDCMImageIO ImageIOType;
<br> ImageIOType::Pointer dicomIO = ImageIOType::New();
<br> dicomIO->SetMaxSizeLoadEntry(0xffff);
<br> readerSerie->SetImageIO( dicomIO );
<br> ImageSerieTypeRGB::Pointer imP;
<br> imP = readerSerie->GetOutput();
<br> try
<br> {
<br> readerSerie->Update();
<br> }
<br> catch( ... )
<br> {
<br> std::cout << "Problemas leyendo la serie" << std::endl;
<br> return 1;
<br> }
<br> std::cout << "...Cargada la Serie Dicom" << std::endl;
<br> <br> <br> std::cout << std::endl;
<br> std::cout << "Para instrucciones sobre cómo manejar la ventana," << std::endl;
<br> std::cout << " teclea 'h' dentro de la ventana" << std::endl;
<br>
<br> form = make_window();
<br> <br> tkMain->label(fName);
<br>
<br> tkWin->SetInputImage(imP);
<br>
<br> form->show();
<br> tkWin->show();
<br> tkWin->update();
<br> <br> Fl::run();
<br>
<br> return 1;
<br> }
<br clear="all"><br><br><br>It works right, but I need to know the name of the 2D slice image wich is visualized in each moment, I mean, the name of current slice in the viewer (not number, the name of the 2d image). This is for show a information about this image generated by me lately. How can I do this? Perharps I should add any code to FltkImageViewer in the following part to change the current image at the same time I press '.' or ',' keyboards to go next or previous slice.<br>
<br><br>case ',':
<br> //when pressing down ">" or "<" key, scrolling will go faster
<br> if( fastMov < fastMovThresh)
<br> {
<br> fastMov ++;
<br> pace = 1;
<br> }
<br> else
<br> {
<br> pace = fastMovVal;
<br> }
<br> if((int)cWinCenter[cWinOrder[2]]-pace<0)
<br> {
<br> if( (int)cWinCenter[cWinOrder[2]] == 0)
<br> return 1;
<br> else
<br> sliceNum(0);
<br> }
<br> else
<br> sliceNum((int)cWinCenter[cWinOrder[2]]-pace);
<br> this->update();
<br> return 1;
<br> break;
<br> case '>':
<br> case '.':
<br> //when pressing down ">" or "<" key, scrolling will go faster
<br> if( fastMov < fastMovThresh)
<br> {
<br> fastMov ++;
<br> pace = 1;
<br> }
<br> else
<br> {
<br> pace = fastMovVal;
<br> }
<br> if((int)cWinCenter[cWinOrder[2]]+pace>(int)cDimSize[cWinOrder[2]]-1)
<br> {
<br> if((int)cWinCenter[cWinOrder[2]] == (int)cDimSize[cWinOrder[2]]-1)
<br> return 1;
<br> else
<br> sliceNum((int)cDimSize[cWinOrder[2]]-1);
<br> }
<br> else
<br> sliceNum(cWinCenter[cWinOrder[2]]+pace);
<br> this->update();
<br> return 1;
<br> break;<br><br>Can anybody helps me?<br>-- <br>Esther.
</div>