diff --git a/Code/FeatureExtraction/otbAddCarvingPathFilter.txx b/Code/FeatureExtraction/otbAddCarvingPathFilter.txx index 31a9b29d9e5bbc816dc099196dbd51c45a559f23..d7e5682e5cf70a115fb75c8eb87500d33c5bd85b 100644 --- a/Code/FeatureExtraction/otbAddCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbAddCarvingPathFilter.txx @@ -20,6 +20,7 @@ #define __otbAddCarvingPathFilter_txx #include "otbAddCarvingPathFilter.h" +#include "itkMacro.h" namespace otb { @@ -82,6 +83,7 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> typename InputPathType::VertexListType::ConstPointer vertexList = inputPath->GetVertexList(); typename InputPathType::VertexListType::ConstIterator pathIterator; typename InputImageType::IndexType indexToAdd; + typedef typename InputImageType::IndexType::IndexValueType IndexValueType; typename InputImageType::SizeType inputSize; inputSize = inputImage->GetLargestPossibleRegion().GetSize(); @@ -112,20 +114,18 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> --pathIterator; if(index[dir1] != indexToAdd[dir1]) { - std::cout << "Error : " << index[dir1] << " , " << indexToAdd[dir1] << std::endl; + itkExceptionMacro(<< "Error : " << index[dir1] << " , " << indexToAdd[dir1]); } } - if (flag || ((index[dir0] != indexToAdd[dir0]) && (index[dir0] < inputSize[dir0]))) + if ( (flag==true) || ((index[dir0] != indexToAdd[dir0]) && (index[dir0] < static_cast<IndexValueType>(inputSize[dir0])))) { outputIterator.Set(inputIterator.Get()); ++inputIterator; } else { -// std::cout << "Adding the value at " << outputIterator.GetIndex() << std::endl; flag = true; -// std::cout << "[" << index[0] << "," << index[1] << "] "; OutputImagePixelType newValue; newValue = (--inputIterator).Get(); newValue += (++inputIterator).Get(); @@ -139,7 +139,7 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> if((outputIterator.GetIndex())[dir0] != (inputIterator.GetIndex())[dir0]+1) { - std::cout << "Error 2: "<< (outputIterator.GetIndex())[dir0] << " , " << (inputIterator.GetIndex())[dir0] << std::endl; + itkExceptionMacro(<< "Error 2: "<< (outputIterator.GetIndex())[dir0] << " , " << (inputIterator.GetIndex())[dir0]); } inputIterator.NextLine(); outputIterator.NextLine(); diff --git a/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx b/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx index b051badd27de33bab023978c7521c8053542726a..89542db21ebe12b3c48bd0ccfb16ee90ada4fd51 100644 --- a/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx @@ -81,47 +81,33 @@ ImageToCarvingPathFilter<TInputImage, TOutputPath> typename IteratorType::OffsetType NEXT; - if (m_Direction == 0) - { - dir0=0; - dir1=1; - const typename IteratorType::OffsetType LEFT ={{-1,0}}; const typename IteratorType::OffsetType RIGHT ={{1,0}}; const typename IteratorType::OffsetType UP ={{0,-1}}; const typename IteratorType::OffsetType DOWN ={{0,1}}; const typename IteratorType::OffsetType LEFTUP ={{-1,-1}}; - const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; +// const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; const typename IteratorType::OffsetType RIGHTUP ={{1,-1}}; const typename IteratorType::OffsetType LEFTDOWN ={{-1,1}}; - const typename IteratorType::OffsetType CENTER ={{0,0}}; - +// const typename IteratorType::OffsetType CENTER ={{0,0}}; + + if (m_Direction == 0) + { + dir0=0; + dir1=1; UP0 = LEFTUP; UP1 = UP; UP2 = RIGHTUP; NEXT = DOWN; - } else { dir0=1; dir1=0; - - const typename IteratorType::OffsetType LEFT ={{-1,0}}; - const typename IteratorType::OffsetType RIGHT ={{1,0}}; - const typename IteratorType::OffsetType UP ={{0,-1}}; - const typename IteratorType::OffsetType DOWN ={{0,1}}; - const typename IteratorType::OffsetType LEFTUP ={{-1,-1}}; - const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; - const typename IteratorType::OffsetType RIGHTUP ={{1,-1}}; - const typename IteratorType::OffsetType LEFTDOWN ={{-1,1}}; - const typename IteratorType::OffsetType CENTER ={{0,0}}; - UP0 = LEFTUP; UP1 = LEFT; UP2 = LEFTDOWN; NEXT = RIGHT; - } /** Compute the energy image top-down or left-right diff --git a/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx b/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx index 74b83c7dbde587149a5091887999904c365d4fac..bb2a0dee22fbb3d07bfc282d5db3f40bc57aef30 100644 --- a/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx @@ -20,6 +20,7 @@ #define __otbRemoveCarvingPathFilter_txx #include "otbRemoveCarvingPathFilter.h" +#include "itkMacro.h" namespace otb { @@ -108,7 +109,7 @@ RemoveCarvingPathFilter<TInputImage,TInputPath,TOutputImage> --pathIterator; if(index[dir1] != indexToRemove[dir1]) { - std::cout << "Error!!!" << std::endl; + itkExceptionMacro(<< "Error!!!"); } } if (index[dir0] != indexToRemove[dir0])