Commit ea78cfb9 authored by Gaetano Raffaele's avatar Gaetano Raffaele

FIX: Changed long unsigned int to std::size_t and long int to __int64 for...

FIX: Changed long unsigned int to std::size_t and long int to __int64 for 64bit node ids under Windows.
parent c4115e48
...@@ -43,7 +43,7 @@ namespace grm ...@@ -43,7 +43,7 @@ namespace grm
Node is identified by the location Node is identified by the location
of the first pixel of the region. of the first pixel of the region.
*/ */
long unsigned int m_Id; std::size_t m_Id;
/* /*
Bounding box of the region Bounding box of the region
...@@ -77,7 +77,6 @@ namespace grm ...@@ -77,7 +77,6 @@ namespace grm
return ptr; return ptr;
} }
}; };
template<class DerivedNode> template<class DerivedNode>
struct Node : BaseNode struct Node : BaseNode
......
...@@ -39,7 +39,7 @@ namespace grm ...@@ -39,7 +39,7 @@ namespace grm
{ {
for(auto& r : seg.m_Graph.m_Nodes) for(auto& r : seg.m_Graph.m_Nodes)
{ {
long int neighborhood[4]; __int64 neighborhood[4];
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)
{ {
...@@ -53,7 +53,7 @@ namespace grm ...@@ -53,7 +53,7 @@ namespace grm
{ {
for(auto& r : seg.m_Graph.m_Nodes) for(auto& r : seg.m_Graph.m_Nodes)
{ {
long int neighborhood[8]; __int64 neighborhood[8];
EIGHTNeighborhood(neighborhood, r->m_Id, width, height); EIGHTNeighborhood(neighborhood, r->m_Id, width, height);
bool haveNeighbors = false; bool haveNeighbors = false;
for(short j = 0; j < 8; ++j) for(short j = 0; j < 8; ++j)
...@@ -79,7 +79,7 @@ namespace grm ...@@ -79,7 +79,7 @@ namespace grm
void GraphOperations<TSegmenter>::UpdateMergingCosts(SegmenterType& seg) void GraphOperations<TSegmenter>::UpdateMergingCosts(SegmenterType& seg)
{ {
float min_cost; float min_cost;
long unsigned int min_id = 0; std::size_t min_id = 0;
std::size_t idx, min_idx; std::size_t idx, min_idx;
for(auto& r : seg.m_Graph.m_Nodes) for(auto& r : seg.m_Graph.m_Nodes)
...@@ -145,18 +145,21 @@ namespace grm ...@@ -145,18 +145,21 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType typename GraphOperations<TSegmenter>::NodePointerType
GraphOperations<TSegmenter>::CheckLMBF(NodePointerType a, float t) GraphOperations<TSegmenter>::CheckLMBF(NodePointerType a, float t)
{ {
if(a->m_Valid) // TO FIX: if no-data are present within the image, an edgeless node is possible
// Here we check if the list of edges is empty prior to cost check.
// if(a->m_Valid)
if(a->m_Valid && a->m_Edges.size() > 0)
{ {
float cost = a->m_Edges.front().m_Cost; float cost = a->m_Edges.front().m_Cost;
if(cost < t) if(cost < t)
{ {
NodePointerType b = a->m_Edges.front().GetRegion(); NodePointerType b = a->m_Edges.front().GetRegion();
if( b->m_Valid) if( b->m_Valid)
{ {
NodePointerType best_b = b->m_Edges.front().GetRegion(); NodePointerType best_b = b->m_Edges.front().GetRegion();
if(a == best_b) if(a == best_b)
{ {
if(a->m_Id < b->m_Id) if(a->m_Id < b->m_Id)
...@@ -174,7 +177,10 @@ namespace grm ...@@ -174,7 +177,10 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType typename GraphOperations<TSegmenter>::NodePointerType
GraphOperations<TSegmenter>::CheckBF(NodePointerType a, float t) GraphOperations<TSegmenter>::CheckBF(NodePointerType a, float t)
{ {
if(a->m_Valid) // TO FIX: if no-data are present within the image, an edgeless node is possible
// Here we check if the list of edges is empty prior to cost check.
// if(a->m_Valid)
if(a->m_Valid && a->m_Edges.size() > 0)
{ {
float cost = a->m_Edges.front().m_Cost; float cost = a->m_Edges.front().m_Cost;
...@@ -318,7 +324,7 @@ namespace grm ...@@ -318,7 +324,7 @@ namespace grm
/* Update the costs of merging between adjacent nodes */ /* Update the costs of merging between adjacent nodes */
UpdateMergingCosts(seg); UpdateMergingCosts(seg);
for(auto& region : seg.m_Graph.m_Nodes) for(auto& region : seg.m_Graph.m_Nodes)
{ {
...@@ -412,7 +418,7 @@ namespace grm ...@@ -412,7 +418,7 @@ namespace grm
{ {
bool merged = false; bool merged = false;
std::vector<long unsigned int> randomIndices(seg.m_Graph.m_Nodes.size()); std::vector<std::size_t> randomIndices(seg.m_Graph.m_Nodes.size());
std::iota(randomIndices.begin(), randomIndices.end(), 0); std::iota(randomIndices.begin(), randomIndices.end(), 0);
std::shuffle(randomIndices.begin(), randomIndices.end(), std::mt19937{std::random_device{}()}); std::shuffle(randomIndices.begin(), randomIndices.end(), std::mt19937{std::random_device{}()});
......
...@@ -18,17 +18,19 @@ ...@@ -18,17 +18,19 @@
#ifndef GRM_NEIGHBORHOOD_H #ifndef GRM_NEIGHBORHOOD_H
#define GRM_NEIGHBORHOOD_H #define GRM_NEIGHBORHOOD_H
#include <cstddef>
enum CONNECTIVITY{FOUR = 0, EIGHT}; enum CONNECTIVITY{FOUR = 0, EIGHT};
namespace grm namespace grm
{ {
void FOURNeighborhood(long int * neighborhood, void FOURNeighborhood(__int64 * neighborhood,
const long unsigned int id, const std::size_t id,
const unsigned int width, const unsigned int width,
const unsigned int height); const unsigned int height);
void EIGHTNeighborhood(long int * neighborhood, void EIGHTNeighborhood(__int64 * neighborhood,
const long unsigned int id, const std::size_t id,
const unsigned int width, const unsigned int width,
const unsigned int height); const unsigned int height);
} // end of namespace grm } // end of namespace grm
......
...@@ -129,7 +129,7 @@ namespace grm ...@@ -129,7 +129,7 @@ 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();
const long unsigned int num_nodes = this->m_ImageWidth * this->m_ImageHeight; const std::size_t num_nodes = this->m_ImageWidth * this->m_ImageHeight;
this->m_Graph.m_Nodes.reserve(num_nodes); this->m_Graph.m_Nodes.reserve(num_nodes);
std::vector<bool> noDataFlags; std::vector<bool> noDataFlags;
...@@ -163,7 +163,6 @@ namespace grm ...@@ -163,7 +163,6 @@ namespace grm
this->m_Graph.m_Nodes.push_back(n); this->m_Graph.m_Nodes.push_back(n);
++idx; ++idx;
} }
} }
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
namespace grm namespace grm
{ {
void FOURNeighborhood(long int * neighborhood, void FOURNeighborhood(__int64 * neighborhood,
const long unsigned int id, const std::size_t id,
const unsigned int width, const unsigned int width,
const unsigned int height) const unsigned int height)
{ {
const unsigned int x = id % width; const std::size_t x = id % width;
const unsigned int y = id / width; const std::size_t y = id / width;
/* top */ /* top */
neighborhood[0] = ( y > 0 ? (id - width) : -1 ); neighborhood[0] = ( y > 0 ? (id - width) : -1 );
...@@ -40,13 +40,13 @@ namespace grm ...@@ -40,13 +40,13 @@ namespace grm
neighborhood[3] = ( x > 0 ? (id - 1) : -1 ); neighborhood[3] = ( x > 0 ? (id - 1) : -1 );
} }
void EIGHTNeighborhood(long int * neighborhood, void EIGHTNeighborhood(__int64 * neighborhood,
const long unsigned int id, const std::size_t id,
const unsigned int width, const unsigned int width,
const unsigned int height) const unsigned int height)
{ {
const unsigned int x = id % width; const std::size_t x = id % width;
const unsigned int y = id / width; const std::size_t y = id / width;
/* top */ /* top */
neighborhood[0] = ( y > 0 ? (id - width) : -1 ); neighborhood[0] = ( y > 0 ? (id - width) : -1 );
......
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