|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef BORDERS_EXTRACTOR_H
|
|
Toshihiro Shimizu |
890ddd |
#define BORDERS_EXTRACTOR_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "runsmap.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "raster_edge_iterator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace TRop
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
namespace borders
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Pixel Selector model
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
This class is just a stub for pixel selector classes.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Pixel Selectors are objects used in raster borders recognition
|
|
Toshihiro Shimizu |
890ddd |
to interpret a raster's pixels and direct edge iterators.
|
|
Toshihiro Shimizu |
890ddd |
\n\n
|
|
Toshihiro Shimizu |
890ddd |
The main purpose of this class is that of distinguishing pixels
|
|
Toshihiro Shimizu |
890ddd |
from their values <\I>. Values are the actual entities recognized
|
|
Toshihiro Shimizu |
890ddd |
in the borders extraction process - adjacent pixels that are cast to
|
|
Toshihiro Shimizu |
890ddd |
the same value will be included in the same border.
|
|
Toshihiro Shimizu |
890ddd |
\n\n
|
|
Toshihiro Shimizu |
890ddd |
For example, if we want to extract the borders of a fullcolor image
|
|
Toshihiro Shimizu |
890ddd |
that separate bright areas from dark ones, we can just have a pixel selector
|
|
Toshihiro Shimizu |
890ddd |
cast each pixel to the integer value 0 if the pixel's value is below the
|
|
Toshihiro Shimizu |
890ddd |
brigthness threshold, and 1 if above.
|
|
Toshihiro Shimizu |
890ddd |
\n\n
|
|
Toshihiro Shimizu |
890ddd |
Also, pixel selectors tell whether pixels are to be intended as
|
|
Toshihiro Shimizu |
890ddd |
completely transparent (virtual pixels outside the raster boundaries are).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
template <typename pix,="" typename="" val=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
class pixel_selector
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef Pix pixel_type; //!< The pixel type naming the selector
|
|
Toshihiro Shimizu |
890ddd |
typedef Val value_type; //!< A value type representing pixel contents.
|
|
Toshihiro Shimizu |
890ddd |
//!< Typically the pixel itself.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
value_type value(const pixel_type &pix) const;
|
|
Toshihiro Shimizu |
890ddd |
bool equal(const pixel_type &a, const pixel_type &b) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value(a) == value(b);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
value_type transparent() const;
|
|
Toshihiro Shimizu |
890ddd |
bool transparent(const pixel_type &pix) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value(pix) == transparent();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns whether a border point must be read or not (corners are always read).
|
|
Toshihiro Shimizu |
890ddd |
bool skip(const value_type &prevLeftValue, const value_type &leftValue) const { return true; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum RunType { _BORDER_LEFT = 0x20,
|
|
Toshihiro Shimizu |
890ddd |
_BORDER_RIGHT = 0x10,
|
|
Toshihiro Shimizu |
890ddd |
_HIERARCHY_INCREASE = 0x8,
|
|
Toshihiro Shimizu |
890ddd |
_HIERARCHY_DECREASE = 0x4 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
Reads the borders of the input raster, according to the specified selector.
|
|
Toshihiro Shimizu |
890ddd |
Outputs the borders by supplying a container reader with the raster edge iterators
|
|
Toshihiro Shimizu |
890ddd |
corresponding to border vertices. The runsmap used in the process can be
|
|
Toshihiro Shimizu |
890ddd |
returned in output.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
template <typename containerreader="" pixel,="" pixelselector,="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
void readBorders(const TRasterPT<pixel> &raster, const PixelSelector &selector,</pixel>
|
|
Toshihiro Shimizu |
890ddd |
ContainerReader &reader, RunsMapP *rasterRunsMap = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename containersreader="" mesh,="" pixelselector,="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
void readMeshes(const TRasterPT<typename pixelselector::pixel_type=""> &raster, const PixelSelector &selector,</typename>
|
|
Toshihiro Shimizu |
890ddd |
ContainersReader &meshesDataReader, RunsMapP *rasterRunsMap = 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} //namespace TRop::borders
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //BORDERS_EXTRACTOR_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef INCLUDE_HPP
|
|
Toshihiro Shimizu |
890ddd |
#include "borders_extractor.hpp"
|
|
Toshihiro Shimizu |
890ddd |
#endif //INCLUDE_HPP
|