[Insight-users] ImageViewer for itkImage?

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Wed Jul 22 04:16:46 EDT 2009


 

Hi Nitin,

 

I do not work with dicom files, however i just had a quick look into the
itk files and found an example to view dicom images.

Please have a look at the file:

InsightApplication/dicomimageviewer/dicomimageviewer.cpp

 

Dicomimageviewer.ccp code given below:

/*======================================================================
===

 

  Program:   Insight Segmentation & Registration Toolkit

  Module:    $RCSfile: DicomImageViewer.cxx,v $

  Language:  C++

  Date:      $Date: 2002-08-22 22:48:40 $

  Version:   $Revision: 1.1 $

 

  Copyright (c) 2002 Insight Consortium. All rights reserved.

  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for
details.

 

     This software is distributed WITHOUT ANY WARRANTY; without even 

     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR


     PURPOSE.  See the above copyright notices for more information.

 

========================================================================
=*/

#include <iostream>

 

#include "itkImage.h"

#include "itkImageFileReader.h"

 

#include "fltkImage2DViewer.h"

 

#include "FL/fl_file_chooser.H"

 

 

int usage(void)

   {

   std::cout << "DicomImageViewer" << std::endl;

   std::cout << std::endl;

   std::cout << "DicomImageViewer <Filename>" << std::endl;

   std::cout << std::endl;

 

   return 1;

   }

 

int main(int argc, char **argv)

  {

  typedef itk::Image< float, 2 > ImageType;

 

  char *fName;

  

  if(argc > 2)

    {

    return usage();

    }

   else

    if(argc == 1)

      {

      fName = fl_file_chooser("Pick a DicomImage file", "*.dcm", ".");

      if(fName == NULL || strlen(fName)<1)

        {

        return 0;

        }

      }

    else

      if(argv[1][0] != '-')

        {

        fName = argv[argc-1];

        }

      else

        {

        return usage();

        }

 

  std::cout << "Loading File: " << fName << std::endl;

  typedef itk::ImageFileReader< ImageType > VolumeReaderType;

  VolumeReaderType::Pointer reader = VolumeReaderType::New();

 

  reader->SetFileName(fName);

 

  try

    {

    reader->Update();

    }

  catch( itk::ExceptionObject & exception )

    {

    std::cout << "Problems reading file format" << std::endl;

    std::cout << exception << std::endl;

    return 1;

    }

  std::cout << "...Done Loading File" << std::endl;

 

  typedef fltk::Image2DViewer<ImageType::PixelType> ImageViewerType;

  ImageViewerType::Pointer viewer = ImageViewerType::New();

 

  viewer->SetLabel( fName );

  viewer->SetImage( reader->GetOutput() );

  viewer->Show();

 

  Fl::run();

  

  return 1;

  }

 

Hope this helps you.

Regards,

kana

 

From: nithin shekar [mailto:nithinshekar1 at gmail.com] 
Sent: 21 July 2009 19:02
To: Arunachalam Kana
Subject: Re: [Insight-users] ImageViewer for itkImage?

 

hi..
i have an fltk window in that window if i choose dicom file the dicom
image
should display in fltk window.how i can do that. fltk doesnt support to
dicomreader. itk or vtk wl support.so we have to cal either vtk or
itk.how i
can cal? how to pipeline between fltk and vtk or fltk and itk?
--

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090722/a7a20feb/attachment-0001.htm>


More information about the Insight-users mailing list