[Insight-users] problem in reading .mhd file type

Raviteja, Allaparthi Allaparthi.Raviteja at philips.com
Fri Aug 31 05:29:05 EDT 2012


Hi,

I am trying to run the code for connected component  and I have a problem in reading the   ".mhd  " file. The code and the error are as follows.



#include "stdafx.h"
#include "itkConnectedComponentImageFilter.h"
#include "itkImageIOBase.h"
#include "itkMetaImageIO.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
int main(int argc, char* argv[] )
{
  //typedef unsigned short  InternalPixelType;
                typedef   unsigned char  InternalPixelType;
                const     unsigned int    Dimension = 2;
    typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
  typedef itk::ImageFileReader< InternalImageType > ReaderType;
  typedef itk::ImageFileWriter<  InternalImageType > WriterType;

  typedef itk::ConnectedComponentImageFilter< InternalImageType, InternalImageType > FilterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  FilterType::Pointer filter = FilterType::New();
   char *inputfile="d:\\EnhancedOutputImage2.mhd";
  char *outputfile="d:\\Ccheck.png";
  reader->SetFileName(inputfile);
  filter->SetInput (reader->GetOutput());
  filter->Update();
     try
      {
      writer->SetInput (filter->GetOutput());
      writer->SetFileName( outputfile );
      writer->Update();
      }
   catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception caught !" << std::endl;
    std::cerr << excep << std::endl;
    }
  return EXIT_SUCCESS;

}

Error:
MetaImage: Read: Cannot open data file

I am using InsightToolkit-4.1.0 with Visual Studio 2010 on Windows 7. How do I resolve these errors?
Thank you.
Regards,
Ravi Teja.





________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120831/17177b21/attachment.htm>


More information about the Insight-users mailing list