[Insight-users] I have the problem in executing the dilation code , can any one help ?

Raviteja, Allaparthi Allaparthi.Raviteja at philips.com
Fri Aug 17 04:56:36 EDT 2012


Hi,

I get the following errors when I try to run the following code in command window



#include "stdafx.h"

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkBinaryDilateImageFilter.h"

int main(int argc, char *argv[])
{
  if( argc < 4 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " <inputImage> <outputImage> <radius>";
    std::cerr << std::endl;
    return EXIT_FAILURE;
    }
  typedef unsigned char PixelType;
  const unsigned int Dimension = 2;

  typedef itk::Image< PixelType, Dimension >    ImageType;
  typedef itk::ImageFileReader< ImageType >     ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );

  typedef itk::BinaryBallStructuringElement< PixelType, Dimension > StructuringElementType;
  StructuringElementType structuringElement;
  structuringElement.SetRadius( atoi( argv[3] ) );
  structuringElement.CreateStructuringElement();

  typedef itk::BinaryDilateImageFilter< ImageType, ImageType, StructuringElementType > BinaryDilateImageFilterType;

  BinaryDilateImageFilterType::Pointer dilateFilter = BinaryDilateImageFilterType::New();
  dilateFilter->SetInput( reader->GetOutput() );
  dilateFilter->SetKernel( structuringElement );

  typedef itk::ImageFileWriter< ImageType > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( dilateFilter->GetOutput() );
  writer->SetFileName( argv[2] );

  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & e )
    {
    std::cerr << "Error: " << e << std::endl;
    return EXIT_FAILURE;
    }

  return EXIT_SUCCESS;
}





Error:
itk::ImageFileWriterException (0046ED04)
Location: "void __thiscall itk::ImageFileWriter<class itk::Image<unsigned char,2> >::Write(void)"
File: d:\itk\insighttoolkit-4.1.0\modules\io\imagebase\include\itkimagefilewriter.hxx
Line: 152
Description:  Could not create IO object for file D:\dilatedoutput.jpg
  Tried to create one of the following:
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.



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/20120817/da043cc4/attachment.htm>


More information about the Insight-users mailing list