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
Node is identified by the location
of the first pixel of the region.
*/
long unsigned int m_Id;
std::size_t m_Id;
/*
Bounding box of the region
......@@ -78,7 +78,6 @@ namespace grm
}
};
template<class DerivedNode>
struct Node : BaseNode
{
......
......@@ -39,7 +39,7 @@ namespace grm
{
for(auto& r : seg.m_Graph.m_Nodes)
{
long int neighborhood[4];
__int64 neighborhood[4];
FOURNeighborhood(neighborhood, r->m_Id, width, height);
for(short j = 0; j < 4; ++j)
{
......@@ -53,7 +53,7 @@ namespace grm
{
for(auto& r : seg.m_Graph.m_Nodes)
{
long int neighborhood[8];
__int64 neighborhood[8];
EIGHTNeighborhood(neighborhood, r->m_Id, width, height);
bool haveNeighbors = false;
for(short j = 0; j < 8; ++j)
......@@ -79,7 +79,7 @@ namespace grm
void GraphOperations<TSegmenter>::UpdateMergingCosts(SegmenterType& seg)
{
float min_cost;
long unsigned int min_id = 0;
std::size_t min_id = 0;
std::size_t idx, min_idx;
for(auto& r : seg.m_Graph.m_Nodes)
......@@ -145,7 +145,10 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType
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;
......@@ -174,7 +177,10 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType
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;
......@@ -412,7 +418,7 @@ namespace grm
{
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::shuffle(randomIndices.begin(), randomIndices.end(), std::mt19937{std::random_device{}()});
......
......@@ -18,17 +18,19 @@
#ifndef GRM_NEIGHBORHOOD_H
#define GRM_NEIGHBORHOOD_H
#include <cstddef>
enum CONNECTIVITY{FOUR = 0, EIGHT};
namespace grm
{
void FOURNeighborhood(long int * neighborhood,
const long unsigned int id,
void FOURNeighborhood(__int64 * neighborhood,
const std::size_t id,
const unsigned int width,
const unsigned int height);
void EIGHTNeighborhood(long int * neighborhood,
const long unsigned int id,
void EIGHTNeighborhood(__int64 * neighborhood,
const std::size_t id,
const unsigned int width,
const unsigned int height);
} // end of namespace grm
......
......@@ -129,7 +129,7 @@ namespace grm
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
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);
std::vector<bool> noDataFlags;
......@@ -163,7 +163,6 @@ namespace grm
this->m_Graph.m_Nodes.push_back(n);
++idx;
}
}
......
......@@ -19,13 +19,13 @@
namespace grm
{
void FOURNeighborhood(long int * neighborhood,
const long unsigned int id,
void FOURNeighborhood(__int64 * neighborhood,
const std::size_t id,
const unsigned int width,
const unsigned int height)
{
const unsigned int x = id % width;
const unsigned int y = id / width;
const std::size_t x = id % width;
const std::size_t y = id / width;
/* top */
neighborhood[0] = ( y > 0 ? (id - width) : -1 );
......@@ -40,13 +40,13 @@ namespace grm
neighborhood[3] = ( x > 0 ? (id - 1) : -1 );
}
void EIGHTNeighborhood(long int * neighborhood,
const long unsigned int id,
void EIGHTNeighborhood(__int64 * neighborhood,
const std::size_t id,
const unsigned int width,
const unsigned int height)
{
const unsigned int x = id % width;
const unsigned int y = id / width;
const std::size_t x = id % width;
const std::size_t y = id / width;
/* top */
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