Commit b9f39c5f500366dca4a935d556aa8266eb0a23a4

Authored by Rémi Cresson (IRSTEA)
1 parent 7762ef1f
Exists in master

Keep projection, origin, and spacing from the input image

Showing 1 changed file with 26 additions and 4 deletions   Show diff stats
app/GenericRegionMerging.cxx
... ... @@ -51,7 +51,8 @@ namespace otb
51 51 SetDescription("This application allows to use the Generic Region Merging library (GRM) and provides currently 3 homogeneity criteria: Euclidean Distance, Full Lambda Schedule and Baatz & Schape criterion.");
52 52  
53 53 AddParameter(ParameterType_InputImage, "in", "Input Image");
54   - AddParameter(ParameterType_OutputImage, "out", "Ouput Label Image");
  54 + AddParameter(ParameterType_OutputImage, "out", "Ouput Label Image");
  55 +// AddParameter(ParameterType_OutputImage, "outrvb", "Ouput Label Image (RVB 8bits)");
55 56  
56 57 AddParameter(ParameterType_Choice, "criterion", "Homogeneity criterion to use");
57 58 AddChoice("criterion.bs", "Baatz & Schape");
... ... @@ -98,6 +99,11 @@ namespace otb
98 99 const unsigned int niter = GetParameterInt("niter");
99 100 const int speed = GetParameterInt("speed");
100 101  
  102 + // Output images
  103 + LabelImageType::Pointer labelImage = LabelImageType::New();
  104 + typedef otb::VectorImage<unsigned char, 2> RGBLabelImageType;
  105 + RGBLabelImageType::Pointer rvbLabelImage = RGBLabelImageType::New();
  106 +
101 107 if(selectedCriterion == "bs")
102 108 {
103 109 const float cw = GetParameterFloat("cw");
... ... @@ -120,7 +126,8 @@ namespace otb
120 126  
121 127 segmenter.Update();
122 128  
123   - SetParameterOutputImage<LabelImageType>("out", segmenter.GetLabeledClusteredOutput());
  129 + labelImage = segmenter.GetLabeledClusteredOutput();
  130 +// rvbLabelImage = segmenter.GetClusteredImageOutput();
124 131 }
125 132 else if(selectedCriterion == "ed")
126 133 {
... ... @@ -135,7 +142,8 @@ namespace otb
135 142  
136 143 segmenter.Update();
137 144  
138   - SetParameterOutputImage<LabelImageType>("out", segmenter.GetLabeledClusteredOutput());
  145 + labelImage = segmenter.GetLabeledClusteredOutput();
  146 +// rvbLabelImage = segmenter.GetClusteredImageOutput();
139 147 }
140 148 else if(selectedCriterion == "fls")
141 149 {
... ... @@ -150,8 +158,22 @@ namespace otb
150 158  
151 159 segmenter.Update();
152 160  
153   - SetParameterOutputImage<LabelImageType>("out", segmenter.GetLabeledClusteredOutput());
  161 + labelImage = segmenter.GetLabeledClusteredOutput();
  162 + rvbLabelImage = segmenter.GetClusteredImageOutput();
154 163 }
  164 +
  165 + // Set output image projection, origin and spacing for labelImage
  166 + labelImage->SetProjectionRef(image->GetProjectionRef());
  167 + labelImage->SetOrigin(image->GetOrigin());
  168 + labelImage->SetSpacing(image->GetSpacing());
  169 + SetParameterOutputImage<LabelImageType>("out", labelImage);
  170 +
  171 +// // Set output image projection, origin and spacing for RVB labelImage
  172 +// rvbLabelImage->SetProjectionRef(image->GetProjectionRef());
  173 +// rvbLabelImage->SetOrigin(image->GetOrigin());
  174 +// rvbLabelImage->SetSpacing(image->GetSpacing());
  175 +// SetParameterOutputImage<RGBLabelImageType>("outrvb", rvbLabelImage);
  176 +
155 177 }
156 178 };
157 179 } // end of namespace Wrapper
... ...