Une mise-à-jour est prévue le 9 juillet entre 13:00 et 14:00. Le service sera inaccessible ou instable pendant cette période. Merci de votre compréhension.

Commit 273d9b6a authored by remi cresson's avatar remi cresson

ENH: raffale patch for no-data

parent 70a3f75e
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <otbImageFileReader.h> #include <otbImageFileReader.h>
#include <itkImageRegionIterator.h> #include <itkImageRegionIterator.h>
#include "grmBaatzSegmenter.h" #include "grmBaatzSegmenter.h"
#include "otbNoDataHelper.h"
namespace grm namespace grm
{ {
...@@ -34,10 +35,19 @@ namespace grm ...@@ -34,10 +35,19 @@ namespace grm
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1]; this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel(); this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel();
std::vector<bool> noDataFlags;
std::vector<double> noDataValues;
bool noDataPresent = otb::ReadNoDataFlags(this->m_InputImage->GetMetaDataDictionary(),noDataFlags,noDataValues);
std::size_t idx = 0; std::size_t idx = 0;
ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion()); ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion());
for(it.GoToBegin(); !it.IsAtEnd(); ++it) for(it.GoToBegin(); !it.IsAtEnd(); ++it)
{ {
if (noDataPresent && otb::IsNoData<double>(it.Get(),noDataFlags,noDataValues)) {
this->m_Graph.m_Nodes[idx]->m_Expired = true;
} else {
this->m_Graph.m_Nodes[idx]->m_Means.reserve(this->m_NumberOfComponentsPerPixel); this->m_Graph.m_Nodes[idx]->m_Means.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_SquareMeans.reserve(this->m_NumberOfComponentsPerPixel); this->m_Graph.m_Nodes[idx]->m_SquareMeans.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_SpectralSum.reserve(this->m_NumberOfComponentsPerPixel); this->m_Graph.m_Nodes[idx]->m_SpectralSum.reserve(this->m_NumberOfComponentsPerPixel);
...@@ -49,6 +59,7 @@ namespace grm ...@@ -49,6 +59,7 @@ namespace grm
this->m_Graph.m_Nodes[idx]->m_SquareMeans.push_back((it.Get()[b])*(it.Get()[b])); this->m_Graph.m_Nodes[idx]->m_SquareMeans.push_back((it.Get()[b])*(it.Get()[b]));
this->m_Graph.m_Nodes[idx]->m_SpectralSum.push_back(it.Get()[b]); this->m_Graph.m_Nodes[idx]->m_SpectralSum.push_back(it.Get()[b]);
} }
}
++idx; ++idx;
} }
} }
......
...@@ -63,6 +63,8 @@ namespace grm ...@@ -63,6 +63,8 @@ namespace grm
seg.m_Graph.m_Nodes.push_back(n); seg.m_Graph.m_Nodes.push_back(n);
} }
seg.InitFromImage();
if(mask == FOUR) if(mask == FOUR)
{ {
for(auto& r : seg.m_Graph.m_Nodes) for(auto& r : seg.m_Graph.m_Nodes)
...@@ -71,7 +73,7 @@ namespace grm ...@@ -71,7 +73,7 @@ namespace grm
FOURNeighborhood(neighborhood, r->m_Id, width, height); FOURNeighborhood(neighborhood, r->m_Id, width, height);
for(short j = 0; j < 4; ++j) for(short j = 0; j < 4; ++j)
{ {
if(neighborhood[j] > -1) if(neighborhood[j] > -1 && !seg.m_Graph.m_Nodes[neighborhood[j]]->m_Expired)
r->m_Edges.push_back(EdgeType( seg.m_Graph.m_Nodes[neighborhood[j]], 0, 1)); r->m_Edges.push_back(EdgeType( seg.m_Graph.m_Nodes[neighborhood[j]], 0, 1));
} }
} }
...@@ -84,7 +86,7 @@ namespace grm ...@@ -84,7 +86,7 @@ namespace grm
EIGHTNeighborhood(neighborhood, r->m_Id, width, height); EIGHTNeighborhood(neighborhood, r->m_Id, width, height);
for(short j = 0; j < 8; ++j) for(short j = 0; j < 8; ++j)
{ {
if(neighborhood[j] > -1) if(neighborhood[j] > -1 && !seg.m_Graph.m_Nodes[neighborhood[j]]->m_Expired)
{ {
if(j % 2 > 0) if(j % 2 > 0)
r->m_Edges.push_back(EdgeType( seg.m_Graph.m_Nodes[neighborhood[j]], 0, 0)); r->m_Edges.push_back(EdgeType( seg.m_Graph.m_Nodes[neighborhood[j]], 0, 0));
...@@ -94,7 +96,9 @@ namespace grm ...@@ -94,7 +96,9 @@ namespace grm
} }
} }
} }
seg.InitFromImage();
RemoveExpiredNodes(seg.m_Graph);
} }
template<class TSegmenter> template<class TSegmenter>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment