<pre>Dear Luis and all ITK users,<br><br>  I tried the example ImageRegionIterator in the ItkSoftwareGuide-2.4.0(form p738 to p740,and I&#39;ll paste the code below). I typed it according to the<br>guide. And complied it with VC6. But VC6 reported a lot of warnings and link errors.
<br><br>  I didn&#39;t konw which lib to add. So I add a lot such as &quot;ITKBasicFilters ITKCommon ITKIO ITKFltkImageViewer ITKStatistics ITKNumerics&quot;. The warnings<br>were still there, but the errors were reduced to only one. It read LINK : fatal error LNK1104: cannot open file &#39;
<br>ITKBasicFilters.obj&#39; &quot;.<br>  I don&#39;t know how to fix the errors and warnings. Can you help me? And by the way, how can I know which lib is related to my project and I should <br>add it to my project?<br><br>
  Thank you very much in advance!<br><br><br>Regards,<br>Xing-Sheng Liu<br><br>Because the message is too big, I can&#39;t paste the warnings and errors in this mail.<br>You can see them here: <a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=dfgj3tr5_1g4j9q9">
http://docs.google.com/Doc?id=dfgj3tr5_1g4j9q9</a><br><br><br><span style="color: rgb(255, 0, 0); font-weight: bold;">the code is here</span><br>====================================================================================================================================================
<br><br><br><br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageRegionConstIterator.h&quot;<br>#include &quot;itkImageRegionIterator.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h
<br>&quot;<br><br>int main( int argc, char *argv[] )<br>{<br>  if ( argc &lt; 7 )<br>    {<br>      std::cerr &lt;&lt; &quot;Missing parameters. &quot; &lt;&lt; std::endl;<br>      std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;
<br><br>      std::cerr &lt;&lt; argv[0]<br>                &lt;&lt; &quot; inputImageFile outputImageFile startX startY sizeX sizeY&quot;<br>                &lt;&lt; std::endl;<br>      return -1;<br>    }<br><br><br>  const unsigned int Dimension = 2;
<br><br>  <br>  typedef unsigned char PixelType;<br>  typedef itk::Image&lt; PixelType, Dimension &gt;  ImageType;<br>  <br>  typedef itk::ImageRegionConstIterator&lt; ImageType &gt; ConstIteratorType;<br>  typedef itk::ImageRegionIterator&lt; ImageType&gt;       IteratorType;
<br><br>  <br>  typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<br>  typedef itk::ImageFileWriter&lt; ImageType &gt; WriterType;<br><br><br>  ImageType::RegionType inputRegion;<br><br>  ImageType::RegionType::IndexType inputStart;
<br><br>  ImageType::RegionType::SizeType  size;<br><br>  inputStart[0] = ::atoi( argv[3] );<br>  inputStart[1] = ::atoi( argv[4] );<br><br>  size[0]  = ::atoi( argv[5] );<br>  size[1]  = ::atoi( argv[6] );<br><br>  inputRegion.SetSize
<br>( size );<br>  inputRegion.SetIndex( inputStart );<br><br>  ImageType::RegionType outputRegion;<br><br>  ImageType::RegionType::IndexType outputStart;<br><br>  outputStart[0] = 0;<br>  outputStart[1] = 0;<br><br>  outputRegion.SetSize
<br>( size );<br>  outputRegion.SetIndex( outputStart );<br><br><br>  ReaderType::Pointer reader = ReaderType::New();<br>  reader-&gt;SetFileName( argv[1] );<br>  try<br>    {<br>    reader-&gt;Update();<br>    }<br>  catch ( itk::ExceptionObject &amp;err)
<br><br>    {<br>    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>    std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>    return -1;<br>    }<br><br>  if ( ! reader-&gt;GetOutput()-&gt;GetRequestedRegion().IsInside( inputRegion ) )
<br><br>    {<br>    std::cerr &lt;&lt; &quot;Error&quot; &lt;&lt; std::endl;<br>    std::cerr &lt;&lt; &quot;The region &quot; &lt;&lt; inputRegion &lt;&lt; &quot;is not contained within the input image region &quot;<br>
              &lt;&lt; reader-&gt;GetOutput()-&gt;GetRequestedRegion() &lt;&lt; std::endl;<br><br>    return -1;<br>    }<br><br><br>  ImageType::Pointer outputImage = ImageType::New();<br>  outputImage-&gt;SetRegions( outputRegion );
<br>  const ImageType::SpacingType&amp; spacing = reader-&gt;GetOutput()-&gt;GetSpacing();<br><br>  const ImageType::PointType&amp; inputOrigin = reader-&gt;GetOutput()-&gt;GetOrigin();<br>  double   outputOrigin[ Dimension ];
<br><br>  for(unsigned int i=0; i&lt; Dimension; i++)<br>    {<br>    outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i];<br><br>    }<br><br>  outputImage-&gt;SetSpacing( spacing );<br>  outputImage-&gt;SetOrigin(  outputOrigin );
<br>  outputImage-&gt;Allocate();<br><br>  ConstIteratorType inputIt(   reader-&gt;GetOutput(), inputRegion  );<br><br>  IteratorType      outputIt(  outputImage,         outputRegion );<br><br>  for ( inputIt.GoToBegin(), 
outputIt.GoToBegin(); !inputIt.IsAtEnd();<br>        ++inputIt, ++outputIt)<br>    {<br>    outputIt.Set(  inputIt.Get<br>()  );<br>    }<br><br>  <br>  WriterType::Pointer writer = WriterType::New();<br>  writer-&gt;SetFileName( argv[2] );
<br>  writer-&gt;SetInput( outputImage );<br><br>  try<br>    {<br>    writer-&gt;Update();<br>    }<br><br>  catch ( itk::ExceptionObject &amp;err)<br>    {<br>    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; 
<br>    std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>    return -1;   <br>    }<br><br><br><br>  return 0;<br>}<br>======================================================================================================================================================
<br><br style="font-weight: bold; color: rgb(255, 0, 0);"></pre><br><a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=dfgj3tr5_1g4j9q9"></a>