[Insight-users] Erosion program failing at writer Update. Can anyone help?
Chr. Rossmanith
cr at neuro.ma.uni-heidelberg.de
Wed Aug 29 08:55:48 EDT 2012
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.
>
>
> _____________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120829/9b15f1d4/attachment.htm>
More information about the Insight-users
mailing list