[Insight-users] How can I get the current image in this case

Kendra kendracorreo at gmail.com
Tue Jul 15 19:58:39 EDT 2008


Based on ImageColorViewer of InsightApplications I adapted the code to
visualice a dicom rgb serie with 2D slices. The code, named
DicomSeriesColorViewer, looks like:

#include <iostream>

#include "itkImage.h"
#include "itkRGBPixel.h"
#include "itkImageSeriesReader.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkNumericSeriesFileNames.h"
#include <vector>
#include <itksys/SystemTools.hxx>

#include "itkImageFileReader.h"

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_file_chooser.H>
#include "GLColorSliceView.h"
#include "GLSliceView.h"
#include "SliceView.h"

#include "DicomSeriesColorViewerGUI.h"


Fl_Window *form;

int usage(void)
   {
   std::cout << "DicomSeriesColorViewer" << std::endl;
   std::cout << std::endl;
   std::cout << "DicomSeriesColorViewer <DirName>" << std::endl;
   std::cout << std::endl;

   return 1;
   }

int main(int argc, char **argv)
  {
  char *fName;

  if(argc > 2)
    {
    return usage();
    }
   else
    if(argc == 1)
      {
      fName = fl_dir_chooser("Selecciona un directorio contenedor de la
serie dicom", "", 0);
      if(fName == NULL || strlen(fName)<1)
        {
        return 0;
        }
      }
    else
      if(argv[1][0] != '-')
        {
        fName = argv[argc-1];
        }
      else
        {
        return usage();
        }

  std::cout << "Cargando Serie Dicom: " << fName << std::endl;
  typedef itk::RGBPixel< unsigned char> RGBPixelType;
  typedef itk::Image< RGBPixelType, 3 >  ImageSerieTypeRGB;
  typedef itk::ImageSeriesReader< ImageSerieTypeRGB > ReaderSerieType;
  ReaderSerieType::Pointer readerSerie = ReaderSerieType::New();
  typedef itk::GDCMImageIO ImageIOType;
  ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
  namesGenerator->SetInputDirectory(fName);
  const ReaderSerieType::FileNamesContainer & filenames =
namesGenerator->GetInputFileNames();
  readerSerie->SetImageIO( gdcmImageIO );
  readerSerie->SetFileNames(filenames);


      try
            {
                readerSerie->Update();
            }

    catch (itk::ExceptionObject & e)

            {
                std::cerr << "error";
                throw e;
            }

  typedef itk::GDCMImageIO       ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  dicomIO->SetMaxSizeLoadEntry(0xffff);
  readerSerie->SetImageIO( dicomIO );
  ImageSerieTypeRGB::Pointer imP;
  imP = readerSerie->GetOutput();
  try
    {
        readerSerie->Update();
    }
  catch( ... )
    {
        std::cout << "Problemas leyendo la serie" << std::endl;
        return 1;
    }
  std::cout << "...Cargada la Serie Dicom" << std::endl;


  std::cout << std::endl;
  std::cout << "Para instrucciones sobre cómo manejar la ventana," <<
std::endl;
  std::cout << "   teclea 'h' dentro de la ventana" << std::endl;

  form = make_window();

  tkMain->label(fName);

  tkWin->SetInputImage(imP);

  form->show();
  tkWin->show();
  tkWin->update();

  Fl::run();

  return 1;
  }



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.


case ',':
          //when pressing down ">" or "<" key, scrolling will go faster
          if( fastMov < fastMovThresh)
          {
            fastMov ++;
            pace = 1;
          }
          else
          {
            pace = fastMovVal;
          }
          if((int)cWinCenter[cWinOrder[2]]-pace<0)
          {
      if( (int)cWinCenter[cWinOrder[2]] == 0)
          return 1;
      else
        sliceNum(0);
          }
      else
      sliceNum((int)cWinCenter[cWinOrder[2]]-pace);
          this->update();
          return 1;
          break;
        case '>':
        case '.':
          //when pressing down ">" or "<" key, scrolling will go faster
          if( fastMov < fastMovThresh)
          {
            fastMov ++;
            pace = 1;
          }
          else
          {
            pace = fastMovVal;
          }

if((int)cWinCenter[cWinOrder[2]]+pace>(int)cDimSize[cWinOrder[2]]-1)
          {
      if((int)cWinCenter[cWinOrder[2]] == (int)cDimSize[cWinOrder[2]]-1)
        return 1;
      else
        sliceNum((int)cDimSize[cWinOrder[2]]-1);
        }
      else
      sliceNum(cWinCenter[cWinOrder[2]]+pace);
          this->update();
          return 1;
          break;

Can anybody helps me?
-- 
Esther.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080716/9ca36e95/attachment-0001.htm>


More information about the Insight-users mailing list