<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Consolas}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
.MsoChpDefault
        {font-family:"Calibri","sans-serif"}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi,</p>
<p class="MsoNormal">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.</p>
<p class="MsoNormal">The following is the code and the error displayed .</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"stdafx.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"itkImage.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"itkImageFileReader.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"itkImageFileWriter.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"itkBinaryErodeImageFilter.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">#include</span><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:#A31515">"itkBinaryBallStructuringElement.h"</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas; color:blue">int</span><span style="font-size:9.5pt; font-family:Consolas"> main(
<span style="color:blue">int</span> argc, <span style="color:blue">char</span>* argv[] )</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">{</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">if</span>( argc < 4 )</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cerr <<
<span style="color:#A31515">"Usage: "</span> << std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cerr << argv[0] <<
<span style="color:#A31515">" inputImage outputImage radius"</span>;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cerr << std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">return</span> EXIT_FAILURE;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> <span style="color:blue">unsigned</span> <span style="color:blue">
char</span> PixelType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">const</span> <span style="color:blue">unsigned</span> <span style="color:blue">
int</span> Dimension = 2;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> itk::Image< PixelType, Dimension > ImageType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> itk::ImageFileReader< ImageType > ReaderType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> ReaderType::Pointer reader = ReaderType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> reader->SetFileName( argv[1] );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cout<<<span style="color:#A31515">"reader passed"</span><<std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> itk::BinaryBallStructuringElement< PixelType, Dimension ></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> StructuringElementType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> StructuringElementType structuringElement;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> structuringElement.SetRadius( atoi( argv[3] ) );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> structuringElement.CreateStructuringElement();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> itk::BinaryErodeImageFilter< ImageType, ImageType,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> StructuringElementType > BinaryErodeImageFilterType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> BinaryErodeImageFilterType::Pointer dilateFilter =</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> BinaryErodeImageFilterType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> dilateFilter->SetInput( reader->GetOutput() );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> dilateFilter->SetKernel( structuringElement );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cout<<<span style="color:#A31515">"filter passed"</span><<std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">typedef</span> itk::ImageFileWriter< ImageType > WriterType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> WriterType::Pointer writer = WriterType::New();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> writer->SetInput( dilateFilter->GetOutput() );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> writer->SetFileName( argv[2] );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cout<<<span style="color:#A31515">"writer passed"</span><<std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">try</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> writer->Update();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cout<<<span style="color:#A31515">"writer update passed"</span><<std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">catch</span>( itk::ExceptionObject )</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> std::cerr <<
<span style="color:#A31515">"Error: "</span> << std::endl;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">return</span> EXIT_FAILURE;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">
<span style="color:blue">return</span> EXIT_SUCCESS;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:Consolas">}</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">"C:\Users\Documents\Visual Studio 2010\Projects\myNew\Debug\Yam.exe" d:\gray.jpg d:\output.jpg 2</p>
<p class="MsoNormal">reader passed</p>
<p class="MsoNormal">filter passed</p>
<p class="MsoNormal">writer passed</p>
<p class="MsoNormal">Error:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thank you,</p>
<p class="MsoNormal">Yamini.D</p>
<p class="MsoNormal"> </p>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1">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.<br>
</font>
</body>
</html>