<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi,<br>
<br>
try to add reader->Update() after reader->SetFileName().
Otherwise you don't know whether your image could successfully be
read.<br>
<br>
Christina Rossmanith<br>
--<br>
<span
style="font-size:10pt;font-family:"Arial","sans-serif""
lang="EN-GB">Dept. of Neurology</span> <br>
<span
style="font-size:10pt;font-family:"Arial","sans-serif""
lang="EN-GB">University Medical Center Mannheim</span><br>
<br>
Am 21.08.2012 10:59, schrieb D, Yamini:<br>
</div>
<blockquote
cite="mid:3F77CD4DD85BA545A968CC371FC60B18013348DA@011-DB3MPN2-112.MGDPHG.emi.philips.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<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>
<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 color="Gray" face="Arial" 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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_____________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Kitware offers ITK Training Courses, for more information visit:
<a class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>
Please keep messages on-topic and check the ITK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
<br>
</body>
</html>