For a complete description of the ITK Image Iterators and their API, please see the Iterators chapter in the ITK Software Guide. The ITK Software Guide is available in print and as a free .pdf download from http://www.itk.org.
- See also:
- ImageConstIterator
-
ConditionalConstIterator
-
ConstNeighborhoodIterator
-
ConstShapedNeighborhoodIterator
-
ConstSliceIterator
-
CorrespondenceDataStructureIterator
-
FloodFilledFunctionConditionalConstIterator
-
FloodFilledImageFunctionConditionalConstIterator
-
FloodFilledImageFunctionConditionalIterator
-
FloodFilledSpatialFunctionConditionalConstIterator
-
FloodFilledSpatialFunctionConditionalIterator
-
ImageConstIterator
-
ImageConstIteratorWithIndex
-
ImageIterator
-
ImageIteratorWithIndex
-
ImageLinearConstIteratorWithIndex
-
ImageLinearIteratorWithIndex
-
ImageRandomConstIteratorWithIndex
-
ImageRandomIteratorWithIndex
-
ImageRegionConstIterator
-
ImageRegionConstIteratorWithIndex
-
ImageRegionExclusionConstIteratorWithIndex
-
ImageRegionExclusionIteratorWithIndex
-
ImageRegionIterator
-
ImageRegionIteratorWithIndex
-
ImageRegionReverseConstIterator
-
ImageRegionReverseIterator
-
ImageReverseConstIterator
-
ImageReverseIterator
-
ImageSliceConstIteratorWithIndex
-
ImageSliceIteratorWithIndex
-
NeighborhoodIterator
-
PathConstIterator
-
PathIterator
-
ShapedNeighborhoodIterator
-
SliceIterator
-
ImageConstIteratorWithIndex
int main(
int argc,
char *argv[])
{
if (argc < 3)
{
std::cerr << "Missing parameters. " << std::endl;
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile"
<< std::endl;
return -1;
}
const unsigned int Dimension = 2;
ImageType::ConstPointer inputImage;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
try
{
reader->Update();
inputImage = reader->GetOutput();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
ImageType::Pointer outputImage = ImageType::New();
outputImage->SetRegions(inputImage->GetRequestedRegion());
outputImage->CopyInformation(inputImage);
outputImage->Allocate();
IteratorType outputIt(outputImage, outputImage->GetRequestedRegion());
ImageType::IndexType requestedIndex =
outputImage->GetRequestedRegion().GetIndex();
ImageType::SizeType requestedSize =
outputImage->GetRequestedRegion().GetSize();
for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt)
{
ImageType::IndexType idx = outputIt.GetIndex();
idx[0] = requestedIndex[0] + requestedSize[0] - 1 - idx[0];
outputIt.Set(inputImage->GetPixel(idx));
}
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[2]);
writer->SetInput(outputImage);
try
{
writer->Update();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return EXIT_SUCCESS;
}