<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:Calibri}
@font-face
        {font-family:"Segoe UI"}
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"> </p>
<p class="MsoNormal">I am trying to run the code for connected component and I have a problem in reading the “.mhd “ file. The code and the error are as follows.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">#include "stdafx.h"</p>
<p class="MsoNormal">#include "itkConnectedComponentImageFilter.h"</p>
<p class="MsoNormal">#include "itkImageIOBase.h"</p>
<p class="MsoNormal">#include "itkMetaImageIO.h"</p>
<p class="MsoNormal">#include "itkImageFileReader.h"</p>
<p class="MsoNormal">#include "itkImageFileWriter.h"</p>
<p class="MsoNormal">int main(int argc, char* argv[] )</p>
<p class="MsoNormal">{</p>
<p class="MsoNormal"> //typedef unsigned short InternalPixelType;</p>
<p class="MsoNormal"> typedef unsigned char InternalPixelType;</p>
<p class="MsoNormal"> const unsigned int Dimension = 2;</p>
<p class="MsoNormal"> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;</p>
<p class="MsoNormal"> typedef itk::ImageFileReader< InternalImageType > ReaderType;</p>
<p class="MsoNormal"> typedef itk::ImageFileWriter< InternalImageType > WriterType;
</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> typedef itk::ConnectedComponentImageFilter< InternalImageType, InternalImageType > FilterType;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> ReaderType::Pointer reader = ReaderType::New();</p>
<p class="MsoNormal"> WriterType::Pointer writer = WriterType::New();</p>
<p class="MsoNormal"> FilterType::Pointer filter = FilterType::New();</p>
<p class="MsoNormal"> char *inputfile="d:\\EnhancedOutputImage2.mhd";</p>
<p class="MsoNormal"> char *outputfile="d:\\Ccheck.png";</p>
<p class="MsoNormal"> reader->SetFileName(inputfile);</p>
<p class="MsoNormal"> filter->SetInput (reader->GetOutput()); </p>
<p class="MsoNormal"> filter->Update();</p>
<p class="MsoNormal"> try</p>
<p class="MsoNormal"> {</p>
<p class="MsoNormal"> writer->SetInput (filter->GetOutput()); </p>
<p class="MsoNormal"> writer->SetFileName( outputfile );</p>
<p class="MsoNormal"> writer->Update();</p>
<p class="MsoNormal"> }</p>
<p class="MsoNormal"> catch( itk::ExceptionObject & excep )</p>
<p class="MsoNormal"> {</p>
<p class="MsoNormal"> std::cerr << "Exception caught !" << std::endl;</p>
<p class="MsoNormal"> std::cerr << excep << std::endl;</p>
<p class="MsoNormal"> }</p>
<p class="MsoNormal"> return EXIT_SUCCESS;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">}</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Error:</p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Segoe UI","sans-serif"; color:black">MetaImage: Read: Cannot open data file</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Segoe UI","sans-serif"; color:black"> </span></p>
<p class="MsoNormal">I am using InsightToolkit-4.1.0 with Visual Studio 2010 on Windows 7. How do I resolve these errors?</p>
<p class="MsoNormal">Thank you.</p>
<p class="MsoNormal">Regards,</p>
<p class="MsoNormal">Ravi Teja.</p>
<p class="MsoNormal"><span style="font-size:12.0pt; font-family:"Times New Roman","serif""> </span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </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>