<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'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't konw which lib to add. So I add a lot such as "ITKBasicFilters ITKCommon ITKIO ITKFltkImageViewer ITKStatistics ITKNumerics". The warnings<br>were still there, but the errors were reduced to only one. It read LINK : fatal error LNK1104: cannot open file '
<br>ITKBasicFilters.obj' ".<br> I don'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'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 "itkImage.h"<br>#include "itkImageRegionConstIterator.h"<br>#include "itkImageRegionIterator.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h
<br>"<br><br>int main( int argc, char *argv[] )<br>{<br> if ( argc < 7 )<br> {<br> std::cerr << "Missing parameters. " << std::endl;<br> std::cerr << "Usage: " << std::endl;
<br><br> std::cerr << argv[0]<br> << " inputImageFile outputImageFile startX startY sizeX sizeY"<br> << 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< PixelType, Dimension > ImageType;<br> <br> typedef itk::ImageRegionConstIterator< ImageType > ConstIteratorType;<br> typedef itk::ImageRegionIterator< ImageType> IteratorType;
<br><br> <br> typedef itk::ImageFileReader< ImageType > ReaderType;<br> typedef itk::ImageFileWriter< ImageType > 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->SetFileName( argv[1] );<br> try<br> {<br> reader->Update();<br> }<br> catch ( itk::ExceptionObject &err)
<br><br> {<br> std::cerr << "ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> return -1;<br> }<br><br> if ( ! reader->GetOutput()->GetRequestedRegion().IsInside( inputRegion ) )
<br><br> {<br> std::cerr << "Error" << std::endl;<br> std::cerr << "The region " << inputRegion << "is not contained within the input image region "<br>
<< reader->GetOutput()->GetRequestedRegion() << std::endl;<br><br> return -1;<br> }<br><br><br> ImageType::Pointer outputImage = ImageType::New();<br> outputImage->SetRegions( outputRegion );
<br> const ImageType::SpacingType& spacing = reader->GetOutput()->GetSpacing();<br><br> const ImageType::PointType& inputOrigin = reader->GetOutput()->GetOrigin();<br> double outputOrigin[ Dimension ];
<br><br> for(unsigned int i=0; i< Dimension; i++)<br> {<br> outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i];<br><br> }<br><br> outputImage->SetSpacing( spacing );<br> outputImage->SetOrigin( outputOrigin );
<br> outputImage->Allocate();<br><br> ConstIteratorType inputIt( reader->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->SetFileName( argv[2] );
<br> writer->SetInput( outputImage );<br><br> try<br> {<br> writer->Update();<br> }<br><br> catch ( itk::ExceptionObject &err)<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;
<br> std::cerr << err << 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>