Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Cresson Remi
GRM
Commits
273d9b6a
Commit
273d9b6a
authored
Mar 24, 2017
by
remi cresson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: raffale patch for no-data
parent
70a3f75e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
14 deletions
+29
-14
include/grmBaatzSegmenter.txx
include/grmBaatzSegmenter.txx
+22
-11
include/grmGraphOperations.txx
include/grmGraphOperations.txx
+7
-3
No files found.
include/grmBaatzSegmenter.txx
View file @
273d9b6a
...
...
@@ -20,6 +20,7 @@
#include <otbImageFileReader.h>
#include <itkImageRegionIterator.h>
#include "grmBaatzSegmenter.h"
#include "otbNoDataHelper.h"
namespace grm
{
...
...
@@ -34,10 +35,19 @@ namespace grm
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
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;
ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion());
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_SquareMeans.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_SpectralSum.reserve(this->m_NumberOfComponentsPerPixel);
...
...
@@ -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_SpectralSum.push_back(it.Get()[b]);
}
}
++idx;
}
}
...
...
include/grmGraphOperations.txx
View file @
273d9b6a
...
...
@@ -63,6 +63,8 @@ namespace grm
seg.m_Graph.m_Nodes.push_back(n);
}
seg.InitFromImage();
if(mask == FOUR)
{
for(auto& r : seg.m_Graph.m_Nodes)
...
...
@@ -71,7 +73,7 @@ namespace grm
FOURNeighborhood(neighborhood, r->m_Id, width, height);
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));
}
}
...
...
@@ -84,7 +86,7 @@ namespace grm
EIGHTNeighborhood(neighborhood, r->m_Id, width, height);
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)
r->m_Edges.push_back(EdgeType( seg.m_Graph.m_Nodes[neighborhood[j]], 0, 0));
...
...
@@ -94,7 +96,9 @@ namespace grm
}
}
}
seg.InitFromImage();
RemoveExpiredNodes(seg.m_Graph);
}
template<class TSegmenter>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment