[Insight-users] Erosion program failing at writer Update.Can anyone help?

D, Yamini Yamini.D at philips.com
Wed Aug 29 23:49:25 EDT 2012


Hi,

Thanks for responding. Yes reader->Update() was one thing which I tried, the actual mistake was in the CMakelist, altering it solved the problem.



Thank you

>Hi,

>

>try to add reader->Update() after reader->SetFileName(). Otherwise you don't know whether your image could successfully be read.

>

>Christina Rossmanith

>--

>Dept. of Neurology

>University Medical Center Mannheim

>

>Am 21.08.2012 10:59, schrieb D, Yamini:

>>

>> Hi,

>>

>> I am trying to run a program for erosion, after building the project,

>> I run the same in cmd window. I find its failing at " writer->

>>update();"  line.

>>

>> The following is the code and the error displayed .

>>

>> #include"stdafx.h"

>>

>> #include"itkImage.h"

>> #include"itkImageFileReader.h"

>> #include"itkImageFileWriter.h"

>> #include"itkBinaryErodeImageFilter.h"

>> #include"itkBinaryBallStructuringElement.h"

>> intmain( 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] );

>> std::cout<<"reader passed"<<std::endl;

>> typedef itk::BinaryBallStructuringElement< PixelType, Dimension >

>> StructuringElementType;

>> StructuringElementType structuringElement;

>> structuringElement.SetRadius( atoi( argv[3] ) );

>> structuringElement.CreateStructuringElement();

>> typedef itk::BinaryErodeImageFilter< ImageType, ImageType,

>> StructuringElementType > BinaryErodeImageFilterType;

>> BinaryErodeImageFilterType::Pointer dilateFilter =

>> BinaryErodeImageFilterType::New();

>> dilateFilter->SetInput( reader->GetOutput() );

>> dilateFilter->SetKernel( structuringElement );

>> std::cout<<"filter passed"<<std::endl;

>> typedef itk::ImageFileWriter< ImageType > WriterType;

>> WriterType::Pointer writer = WriterType::New();

>> writer->SetInput( dilateFilter->GetOutput() );

>> writer->SetFileName( argv[2] );

>> std::cout<<"writer passed"<<std::endl;

>> try

>>     {

>> writer->Update();

>> std::cout<<"writer update passed"<<std::endl;

>>     }

>> catch( itk::ExceptionObject )

>>     {

>>     std::cerr << "Error: " << std::endl;

>> return EXIT_FAILURE;

>>     }

>> return EXIT_SUCCESS;

>> }

>>

>> "C:\Users\Documents\Visual Studio 2010\Projects\myNew\Debug\Yam.exe"

>> d:\gray.jpg  d:\output.jpg  2

>> reader passed

>> filter passed

>> writer passed

>> Error:

>>

>> Thank you,

>> Yamini.D

________________________________
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/20120830/a84422f6/attachment.htm>


More information about the Insight-users mailing list