Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* Copyright(C) 2005-2020 Centre National d'Etudes Spatiales(CNES)
*
* This file is part of Orfeo Toolbox
*
* https: //www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0(the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http: //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbClampROIFilter.h"
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
namespace otb
{
namespace Wrapper
{
/**
* Application that fills margins to 0.
*
* This application is similar to ExtractROI with the difference the margin is
* kept, and filled with 0.
*
* This application is used to implement the _cut_ processing in S1Tiling
* chain.
*
* \author Luc Hermitte (CS Group)
* \copyright CNES
*/
class ClampROI : public Application
{
public:
using Self = ClampROI;
using Pointer = itk::SmartPointer<Self>;
itkNewMacro(Self);
itkTypeMacro(ClampROI, otb::Wrapper::Application);
private:
void DoInit() override
{
SetName("ClampROI");
SetDescription("This is the ClampROI application, version X.X.X");
SetDocLongDescription(
"This application is similar to ExtractROI in the sense it extracts a Region of Interrest.\n"
"However, the region outside of the ROI isn't trimmed, but set to 0.\n"
"\n"
"The filter set lines of index < threshold.y, and of index >= threshold.y to 0\n"
"The filter set columns of index < threshold.x, and of index >= threshold.x to 0");
SetDocLimitations("This application only works on scalar (and complex) images.");
SetDocAuthors("Luc Hermitte (CS Group)");
SetDocSeeAlso("ManageNoData, ExtractROI");
AddDocTag("otb::Wrapper::Tags::Manip");
AddParameter(ParameterType_InputImage, "in", "Input image");
SetParameterDescription("in", "Scalar Input image");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Scalar Output image");
AddParameter(ParameterType_Group, "threshold", "threshold group");
AddParameter(ParameterType_Group, "threshold.y", "threshold group");
MandatoryOff("threshold");
MandatoryOff("threshold.y");
AddParameter(ParameterType_Int, "threshold.x", "Column index threshold");
SetParameterDescription("threshold.x", "Column index threshold");
SetDefaultParameterInt("threshold.x", 0);
AddParameter(ParameterType_Int, "threshold.y.start", "Top line index threshold");
SetParameterDescription("threshold.y.start", "Top line index threshold");
SetDefaultParameterInt("threshold.y.start", 0);
AddParameter(ParameterType_Int, "threshold.y.end", "Bottom line index threshold");
SetParameterDescription("threshold.y.end", "Bottom line index threshold");
SetDefaultParameterInt("threshold.y.end", 0);
AddRAMParameter();
}
void DoUpdateParameters() override
{}
void DoExecute() override
{
auto const thrX = GetParameterInt("threshold.x");
auto const thrYtop = GetParameterInt("threshold.y.start");
auto const thrYbot = GetParameterInt("threshold.y.end");
if (thrX < 0)
itkExceptionMacro("The column threshold is expected to be positive");
if (thrYtop < 0)
itkExceptionMacro("The top line threshold is expected to be positive");
if (thrYbot < 0)
itkExceptionMacro("The bottom line threshold is expected to be positive");
if (thrX == 0 && thrYtop == 0 && thrYbot == 0)
itkExceptionMacro("Don't use ClampROI to clamp nothing!");
auto filter = ClampROIFilter<FloatImageType>::New();
assert(thrX >= 0);
assert(thrYtop >= 0);
assert(thrYbot >= 0);
filter->SetThresholdX(thrX);
filter->SetThresholdYtop(thrYtop);
filter->SetThresholdYbot(thrYbot);
filter->SetInput(GetParameterFloatImage("in"));
SetParameterOutputImage("out", filter->GetOutput());
RegisterPipeline();
}
};
} // otb::Wrapper namespace
} // otb namespace
OTB_APPLICATION_EXPORT(otb::Wrapper::ClampROI)