Commit db4c9ac6 authored by remi cresson's avatar remi cresson

Merge branch 'msbuild_portability'

Conflicts:
	include/grmGraphOperations.txx
parents 9ef7c889 686636ec
......@@ -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
......@@ -77,7 +77,6 @@ namespace grm
return ptr;
}
};
template<class DerivedNode>
struct Node : BaseNode
......
......@@ -39,7 +39,7 @@ namespace grm
{
for(auto& r : seg.m_Graph.m_Nodes)
{
long int neighborhood[4];
NeighIDType 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];
NeighIDType 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,21 +145,21 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType
GraphOperations<TSegmenter>::CheckLMBF(NodePointerType a, float t)
{
// 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)
// 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;
if(cost < t)
{
NodePointerType b = a->m_Edges.front().GetRegion();
if( b->m_Valid)
{
NodePointerType best_b = b->m_Edges.front().GetRegion();
if(a == best_b)
{
if(a->m_Id < b->m_Id)
......@@ -177,10 +177,10 @@ namespace grm
typename GraphOperations<TSegmenter>::NodePointerType
GraphOperations<TSegmenter>::CheckBF(NodePointerType a, float t)
{
// 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)
// 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;
......@@ -324,7 +324,7 @@ namespace grm
/* Update the costs of merging between adjacent nodes */
UpdateMergingCosts(seg);
for(auto& region : seg.m_Graph.m_Nodes)
{
......@@ -418,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,25 @@
#ifndef GRM_NEIGHBORHOOD_H
#define GRM_NEIGHBORHOOD_H
#include <cstddef>
#if defined(_WIN32)
typedef __int64 NeighIDType;
#else
typedef long int NeighIDType;
#endif
enum CONNECTIVITY{FOUR = 0, EIGHT};
namespace grm
{
void FOURNeighborhood(long int * neighborhood,
const long unsigned int id,
void FOURNeighborhood(NeighIDType * 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(NeighIDType * 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(NeighIDType * 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(NeighIDType * 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