From 2a2fceb8249c7448dbcacd084a998cdbeee16fc3 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Thu, 15 Jan 2009 11:25:31 +0800 Subject: [PATCH] DOC: SiftFastExample correction --- .../FeatureExtraction/SIFTFastExample.cxx | 119 ++++++++---------- 1 file changed, 54 insertions(+), 65 deletions(-) diff --git a/Examples/FeatureExtraction/SIFTFastExample.cxx b/Examples/FeatureExtraction/SIFTFastExample.cxx index 7dbc030fbe..ec73e0df4e 100644 --- a/Examples/FeatureExtraction/SIFTFastExample.cxx +++ b/Examples/FeatureExtraction/SIFTFastExample.cxx @@ -89,7 +89,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet typedef itk::VariableLengthVector<RealType> RealVectorType; typedef itk::PointSet<RealVectorType,Dimension> PointSetType; // Software Guide : EndCodeSnippet @@ -100,7 +100,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet typedef otb::SiftFastImageFilter<ImageType,PointSetType> ImageToFastSIFTKeyPointSetFilterType; @@ -111,7 +111,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(infname); @@ -123,8 +123,8 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + ImageToFastSIFTKeyPointSetFilterType::Pointer filter = ImageToFastSIFTKeyPointSetFilterType::New(); @@ -137,7 +137,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet filter->SetInput(0,reader->GetOutput()); filter->SetNumberOfScales(scales); @@ -152,40 +152,27 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + typedef unsigned char PixelType; typedef itk::RGBPixel<PixelType> RGBPixelType; typedef otb::Image<RGBPixelType, 2> OutputImageType; typedef otb::ImageFileWriter<OutputImageType> WriterType; - + OutputImageType::Pointer outputImage = OutputImageType::New(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex // // We set the regions of the image by copying the information from the -// input image and we allocate the memeory for the output image. +// input image and we allocate the memory for the output image. // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - - - OutputImageType::RegionType region; - - OutputImageType::SizeType outputSize; - outputSize[0] = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0]; - outputSize[1] = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1]; - region.SetSize(outputSize); - - OutputImageType::IndexType indexStart; - indexStart[0] = 0; - indexStart[1] = 0; - region.SetIndex(indexStart); +// Software Guide : BeginCodeSnippet - outputImage->SetRegions(region); + outputImage->SetRegions(reader->GetOutput()->GetLargestPossibleRegion()); outputImage->Allocate(); // Software Guide : EndCodeSnippet @@ -199,12 +186,12 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + itk::ImageRegionIterator<OutputImageType> iterOutput(outputImage, - outputImage->GetLargestPossibleRegion()); + outputImage->GetLargestPossibleRegion()); itk::ImageRegionIterator<ImageType> iterInput(reader->GetOutput(), - reader->GetOutput()->GetLargestPossibleRegion()); + reader->GetOutput()->GetLargestPossibleRegion()); for (iterOutput.GoToBegin(), iterInput.GoToBegin(); !iterOutput.IsAtEnd(); @@ -227,7 +214,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet ImageType::OffsetType t = {{ 0, 1}}; @@ -245,8 +232,8 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + typedef PointSetType::PointsContainer PointsContainerType; typedef PointsContainerType::Iterator PointsIteratorType; @@ -257,8 +244,8 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin(); // Software Guide : EndCodeSnippet @@ -269,8 +256,8 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); ImageType::PointType origin = reader->GetOutput()->GetOrigin(); OutputImageType::SizeType size = outputImage->GetLargestPossibleRegion().GetSize(); @@ -282,9 +269,9 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - - +// Software Guide : BeginCodeSnippet + + while( pIt != filter->GetOutput()->GetPoints()->End() ) { @@ -298,17 +285,19 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + ImageType::IndexType index; - index[0] = (unsigned int) - (vcl_floor - ((double)((pIt.Value()[0]-origin[0])/spacing[0]+0.5))); + index[0] = static_cast<unsigned int>(vcl_floor( + static_cast<double>( + (pIt.Value()[0]-origin[0])/spacing[0] +0.5 + ))); - index[1] = (unsigned int) - (vcl_floor - ((double)((pIt.Value()[1]-origin[1])/spacing[1]+0.5))); + index[1] = static_cast<unsigned int>(vcl_floor( + static_cast<double>( + (pIt.Value()[1]-origin[1])/spacing[1] +0.5 + ))); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -317,8 +306,8 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + OutputImageType::PixelType keyPixel; keyPixel.SetRed(0); keyPixel.SetGreen(255); @@ -333,27 +322,27 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet - +// Software Guide : BeginCodeSnippet + if (outputImage->GetLargestPossibleRegion().IsInside(index)) - { - outputImage->SetPixel(index,keyPixel); + { + outputImage->SetPixel(index,keyPixel); - if (outputImage->GetLargestPossibleRegion().IsInside(index+t)) - outputImage->SetPixel(index+t,keyPixel); + if (outputImage->GetLargestPossibleRegion().IsInside(index+t)) + outputImage->SetPixel(index+t,keyPixel); - if (outputImage->GetLargestPossibleRegion().IsInside(index+b)) - outputImage->SetPixel(index+b,keyPixel); + if (outputImage->GetLargestPossibleRegion().IsInside(index+b)) + outputImage->SetPixel(index+b,keyPixel); - if (outputImage->GetLargestPossibleRegion().IsInside(index+l)) - outputImage->SetPixel(index+l,keyPixel); + if (outputImage->GetLargestPossibleRegion().IsInside(index+l)) + outputImage->SetPixel(index+l,keyPixel); - if (outputImage->GetLargestPossibleRegion().IsInside(index+r)) - outputImage->SetPixel(index+r,keyPixel); - } + if (outputImage->GetLargestPossibleRegion().IsInside(index+r)) + outputImage->SetPixel(index+r,keyPixel); + } ++pIt; } -// Software Guide : EndCodeSnippet +// Software Guide : EndCodeSnippet // Software Guide : BeginLatex // @@ -361,7 +350,7 @@ int main(int argc, char * argv[]) // // Software Guide : EndLatex -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet WriterType::Pointer writer = WriterType::New(); @@ -369,7 +358,7 @@ int main(int argc, char * argv[]) writer->SetInput(outputImage); writer->Update(); -// Software Guide : EndCodeSnippet +// Software Guide : EndCodeSnippet // Software Guide : BeginLatex // Figure~\ref{fig:SIFTFast} shows the result of applying the SIFT -- GitLab