Commit 0a4981ae authored by remicres's avatar remicres

ADD: lsgrm Full Lambda Schedule criterion

parent 55ba05a1
#ifndef __LSRM_FLS_SEGMENTER_H
#define __LSRM_FLS_SEGMENTER_H
#include "lsgrmSegmenter.h"
#include "grmFullLambdaScheduleSegmenter.h"
namespace lsgrm
{
template<class TImage>
class FullLambdaScheduleSegmenter : public Segmenter<grm::FullLambdaScheduleSegmenter<TImage> >
{
public:
/* Some convenient typedefs */
typedef grm::FullLambdaScheduleSegmenter<TImage> Superclass;
typedef typename Superclass::NodeType NodeType;
typedef typename Superclass::EdgeType EdgeType;
typedef typename Superclass::NodePointerType NodePointerType;
FullLambdaScheduleSegmenter(){};
void WriteSpecificAttributes(NodePointerType node, FILE * nodeStream);
void ReadSpecificAttributes(NodePointerType node, FILE * nodeStream);
long long unsigned int GetNodeMemory(NodePointerType &node);
};
} // end of namespace lsrm
#include "lsgrmFullLambdaScheduleSegmenter.txx"
#endif
#ifndef __LSRM_FLS_SEGMENTER_TXX
#define __LSRM_FLS_SEGMENTER_TXX
#include <otbImageFileReader.h>
#include <itkImageRegionIterator.h>
namespace lsgrm
{
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
long long unsigned int
FullLambdaScheduleSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
{
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 1 * nBands * sizeof(float); // size of the 1 attribute, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
} // end of namespace lsrm
#endif
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