Version: 1.0
Public Member Functions | Public Attributes | List of all members
ForestHandler Class Reference

This class allows to generate the forests associated to an algorithm when the pixel prediction is applied. More...

#include <forest_handler.h>

Public Member Functions

 ForestHandler (const BinaryDrag< conact > &bd, const pixel_set &ps, ForestHandlerFlags flag=ForestHandlerFlags::CENTER_LINES|ForestHandlerFlags::FIRST_LINE)
 
void DrawOnFile (const std::string &prefix, DrawDagFlags flags=DrawDagFlags::NONE)
 
void GenerateCode (BEFORE_AFTER_FUNC(before_main)=BeforeMainShiftOne, BEFORE_AFTER_FUNC(after_main)=DefaultEmptyFunc, BEFORE_AFTER_FUNC(before_end)=BeforeEnd, BEFORE_AFTER_FUNC(after_end)=AfterEnd, BEFORE_AFTER_FUNC(after_end_no_loop)=AfterEndNoLoop, int flags=0)
 Generates the code for the all the forests groups, each of them in a separate file. More...
 
void Compress (DragCompressorFlags flags=DragCompressorFlags::PRINT_STATUS_BAR|DragCompressorFlags::IGNORE_LEAVES, int iterations=- 1)
 Compresses all the drags of the forest using an exhaustive approach. More...
 
LineForestHandlerGetLineForestHandler (ForestHandlerFlags forest_id)
 

Public Attributes

std::map< ForestHandlerFlags, LineForestHandlerf_
 
std::map< ForestHandlerFlags, std::string > names
 
std::map< ForestHandlerFlags, std::string > prefixs
 

Detailed Description

This class allows to generate the forests associated to an algorithm when the pixel prediction is applied.

When applying pixel prediction optimization many different forest should be generated. The number of forests depends on the mask size and on vertical shift size. This class considers only Rosenfeld and Grana masks like situations. In the former case the vertical shift is unitary and only first line forests and central lines forest are required. In the latter case the mask has a vertical shift of 2 pixels. In this case four different group of forests are required:

A forest group, defined by the LineForestHandler is composed by a main forest and multiple end of the line forests. The number of the end of the line forest depends on the mask horizontal shift. For unitary shift we will have just one end of the line forest, when the mask has a horizontal shift of two pixels we will have two end of the line forests and so on.

The forests generation requires the original decision tree associated to the algorithm on which apply the prediction optimization and the pixel set associated to the mask. The ForestHandlerFlagg enum class allows to select which kind of forests groups you want the ForestHandler generates for you.

Definition at line 40 of file forest_handler.h.

Constructor & Destructor Documentation

◆ ForestHandler()

ForestHandler::ForestHandler ( const BinaryDrag< conact > &  bd,
const pixel_set ps,
ForestHandlerFlags  flag = ForestHandlerFlags::CENTER_LINES | ForestHandlerFlags::FIRST_LINE 
)
inline

Definition at line 57 of file forest_handler.h.

Member Function Documentation

◆ Compress()

void ForestHandler::Compress ( DragCompressorFlags  flags = DragCompressorFlags::PRINT_STATUS_BAR | DragCompressorFlags::IGNORE_LEAVES,
int  iterations = - 1 
)
inline

Compresses all the drags of the forest using an exhaustive approach.

Parameters
[in]flagsFlags to be used. Available flags are the ones from the DragCompressorFlags enum class. Use the or to combine multiple flags. Default value is DragCompressorFlags::PRINT_STATUS_BAR | DragCompressorFlags::IGNORE_LEAVES.
[in]iterationsAllows to introduce an early stopping criteria. If it is different from -1 the procedure will stop after "iterations" steps, otherwise it will continue until end. Default value is -1.

Definition at line 163 of file forest_handler.h.

◆ DrawOnFile()

void ForestHandler::DrawOnFile ( const std::string &  prefix,
DrawDagFlags  flags = DrawDagFlags::NONE 
)
inline

Definition at line 95 of file forest_handler.h.

◆ GenerateCode()

void ForestHandler::GenerateCode ( BEFORE_AFTER_FUNC(before_main)  = BeforeMainShiftOne,
BEFORE_AFTER_FUNC(after_main)  = DefaultEmptyFunc,
BEFORE_AFTER_FUNC(before_end)  = BeforeEnd,
BEFORE_AFTER_FUNC(after_end)  = AfterEnd,
BEFORE_AFTER_FUNC(after_end_no_loop)  = AfterEndNoLoop,
int  flags = 0 
)
inline

Generates the code for the all the forests groups, each of them in a separate file.

Parameters
[in]before_mainPointer to the function* which defines what the code generator has to write before printing the code of a tree from the main group of a line. An example is provided with the BeforeMainShiftOne (default value), or by the BeforeMainShifTwo function. The function behavior should depends on the horizontal shift of the mask involved
[in]after_mainPointer to the function* which defines what the code generator has to write after printing the code of a tree from the main group of a line. Usually it is empty. The default value is DefaultEmptyFunc.
[in]before_endPointer to the function* which defines what the code generator has to write before printing the code of a tree from the end of the line groups. Usually it is just a label. The default value is BeforeEnd.
[in]after_endPointer to the function* which defines what the code generator has to write after printing the code of a tree from the end of the (CENTER!) line groups. Usually it is just a "continue;" or a "goto". The default value is AfterEnd.
[in]after_end_no_loopPointer to the function* which defines what the code generator has to write after printing the code of a tree from the end of the (NON CENTER!) lines groups. The default value is AfterEndNoLoop.
[in]flagNot used yet. Default value is zero.

all the functions must have the following signature:

std::string fun_name(int index, const std::string& prefix, const std::vector<std::vector<int>>& mapping, int end_group_id)

Definition at line 129 of file forest_handler.h.

◆ GetLineForestHandler()

LineForestHandler& ForestHandler::GetLineForestHandler ( ForestHandlerFlags  forest_id)
inline

Definition at line 169 of file forest_handler.h.

Member Data Documentation

◆ f_

std::map<ForestHandlerFlags, LineForestHandler> ForestHandler::f_

Definition at line 42 of file forest_handler.h.

◆ names

std::map<ForestHandlerFlags, std::string> ForestHandler::names
Initial value:
= {
}
@ FIRST_LINE
Whether to generate the forest for the first line of the image.
@ CENTER_LINES
Whether to generate the forest for the center lines of the image.
@ SINGLE_LINE
Whether to generate the forest for an image composed by a single line.
@ LAST_LINE
Whether to generate the forest for the last line of the image.

Definition at line 43 of file forest_handler.h.

◆ prefixs

std::map<ForestHandlerFlags, std::string> ForestHandler::prefixs

The documentation for this class was generated from the following file: