OTB  9.0.0
Orfeo Toolbox
otbLabelMapWithClassLabelToClassLabelImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbLabelMapWithClassLabelToClassLabelImageFilter_hxx
22 #define otbLabelMapWithClassLabelToClassLabelImageFilter_hxx
23 
25 #include "itkNumericTraits.h"
26 #include "itkProgressReporter.h"
27 #include "itkImageRegionConstIteratorWithIndex.h"
28 
29 namespace otb
30 {
31 
32 template <class TInputImage, class TOutputImage>
34 {
35 }
36 
37 
38 template <class TInputImage, class TOutputImage>
40 {
41  OutputImageType* output = this->GetOutput();
42  const InputImageType* input = this->GetInput();
43  output->FillBuffer(input->GetBackgroundValue());
44  Superclass::BeforeThreadedGenerateData();
45 }
46 
47 
48 template <class TInputImage, class TOutputImage>
50 {
51  typename LabelObjectType::ClassLabelType label = itk::NumericTraits<typename LabelObjectType::ClassLabelType>::max();
52  if (labelObject->HasClassLabel())
53  {
54  label = labelObject->GetClassLabel();
55  }
56 
58 
59  while (!lit.IsAtEnd())
60  {
61  IndexType idx = lit.GetLine().GetIndex();
62  unsigned long length = lit.GetLine().GetLength();
63  for (unsigned int i = 0; i < length; ++i)
64  {
65  this->GetOutput()->SetPixel(idx, label);
66  idx[0]++;
67  }
68  ++lit;
69  }
70 }
71 
72 } // end namespace otb
73 #endif
otb::LabelMapWithClassLabelToClassLabelImageFilter::IndexType
OutputImageType::IndexType IndexType
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.h:60
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbLabelMapWithClassLabelToClassLabelImageFilter.h
otb::LabelMapWithClassLabelToClassLabelImageFilter::LabelObjectType
InputImageType::LabelObjectType LabelObjectType
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.h:52
otb::LabelMapWithClassLabelToClassLabelImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.hxx:39
otb::LabelMapWithClassLabelToClassLabelImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.h:47
otb::LabelMapWithClassLabelToClassLabelImageFilter::LabelMapWithClassLabelToClassLabelImageFilter
LabelMapWithClassLabelToClassLabelImageFilter()
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.hxx:33
otb::LabelMapWithClassLabelToClassLabelImageFilter::InputImageType
TInputImage InputImageType
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.h:46
otb::LabelMapWithClassLabelToClassLabelImageFilter::ConstLineIteratorType
LabelObjectType::ConstLineIterator ConstLineIteratorType
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.h:54
otb::LabelMapWithClassLabelToClassLabelImageFilter::ThreadedProcessLabelObject
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
Definition: otbLabelMapWithClassLabelToClassLabelImageFilter.hxx:49