104 int main(
int argc,
char *argv[])
109 std::cerr <<
"Missing parameters. " << std::endl;
110 std::cerr <<
"Usage: " << std::endl;
112 <<
" inputImageFile outputImageFile"
125 const unsigned int Dimension = 2;
138 ImageType::ConstPointer inputImage;
139 ReaderType::Pointer reader = ReaderType::New();
140 reader->SetFileName(argv[1]);
144 inputImage = reader->GetOutput();
148 std::cout <<
"ExceptionObject caught a !" << std::endl;
149 std::cout << err << std::endl;
161 ImageType::Pointer outputImage = ImageType::New();
162 outputImage->SetRegions(inputImage->GetRequestedRegion());
163 outputImage->CopyInformation(inputImage);
164 outputImage->Allocate();
177 ConstIteratorType inputIt(inputImage, inputImage->GetRequestedRegion());
178 IteratorType outputIt(outputImage, inputImage->GetRequestedRegion());
180 inputIt.SetDirection(0);
181 outputIt.SetDirection(0);
192 for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();
193 outputIt.NextLine(), inputIt.NextLine())
195 inputIt.GoToBeginOfLine();
196 outputIt.GoToEndOfLine();
198 while (!inputIt.IsAtEndOfLine())
200 outputIt.Set(inputIt.Get());
207 WriterType::Pointer writer = WriterType::New();
208 writer->SetFileName(argv[2]);
209 writer->SetInput(outputImage);
216 std::cout <<
"ExceptionObject caught !" << std::endl;
217 std::cout << err << std::endl;