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

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Aug 17 08:40:46 EDT 2012


This is the prototypical example of a basic CMake project for using ITK:

https://github.com/Kitware/ITK/blob/master/Examples/Installation/CMakeLists.txt

What does your CMake code look like?


I am suspicion that the code generated by CMake to automatically register the IO factories did not occur. There should be a directory called "ITKIOFactoryRegistration" created in your build tree. This directory should contain a couple of header files.

Dave could also be correct if you didn't build ITK with all the modules turned on. 

You could also try manually setting the ImageIO for the writer to  itk::JPEGImageIO, simularly to was was done here:

http://www.vtk.org/Wiki/ITK/Examples/IO/TIFFImageIO

Hope this helps,
Brad

On Aug 17, 2012, at 8:28 AM, Raviteja, Allaparthi wrote:

> Hi,
>  
> Ya, I am using “cmake”.
>  
>  
> Regards,
> Ravi Teja.
>  
>  
> From: Bradley Lowekamp [mailto:blowekamp at mail.nih.gov] 
> Sent: Friday, August 17, 2012 5:52 PM
> To: Raviteja, Allaparthi
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] I have the problem in executing the dilation code , can any one help ?
>  
> Hello,
>  
> It sounds like the ImageIO factories are not getting registered automatically.
>  
> Are you using CMake?
>  
> Brad
>  
> On Aug 17, 2012, at 4:56 AM, Raviteja, Allaparthi wrote:
> 
> 
> 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.
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>  
> ========================================================
> Bradley Lowekamp  
> Medical Science and Computing for
> Office of High Performance Computing and Communications
> National Library of Medicine 
> blowekamp at mail.nih.gov
> 
> 
>  
>  

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov



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


More information about the Insight-users mailing list