Class to link detected images edges a typical source can be a cvCanny image. More...
#include <contour.h>
Public Member Functions | |
Contour () | |
void | Draw (unsigned char *pImgRGB) |
Draws the detected contours in a RGB image with radom colours. More... | |
void | GetAbnormitiesInEdgesImage (IplImage *ptImgEdge, std::vector< CvPoint > *pAbnormities, uchar iEdgeStrength=0) |
Find egde contour Abnormities in edge image. More... | |
int | getContours (std::vector< std::vector< cv::Point > > &contours, unsigned min_length=0) |
Returns the contour as vector of vector points. More... | |
int | GetEdgeListSplittedXY (std::vector< cv::Point_< int > > &rEdges, std::vector< unsigned char > **ppAngle8Bit=NULL) |
Returns number of edges and edges in the arguments. More... | |
unsigned int | GetNrOfEdges () |
Returns a number of edges used to linke edges to semgents. More... | |
std::vector< cv::Range > | getSegmentIndexes () |
the indexes of the contour segments More... | |
void | Init (unsigned int iImgWidth, unsigned int iImgHeight, bool bAllowToModifyTheSources=false, unsigned char iEdgeToProcess=0xFF, unsigned char iEdgeInProcess=0xFF-1, unsigned char iEdgeProcessed=0xFF-2, unsigned char iEdgeStrengthRemoved=0) |
Inititalized the class and reserves the momory needed. More... | |
void | Perform (unsigned char *pImgEdgeStrength, int defEdgeLinkMode=MODE_CONTOUR, void *pImgEdgeDirection=NULL, int defImgEdgeDirectionType=ANGLE_8U) |
Starts the edge linking with a certain mode. More... | |
~Contour () | |
Static Public Attributes | |
static const int | ANGLE_32F = 32 |
Static const variable used to define the source format of a gradient image as atan2(dy, dx) of the edge The format ANGLE_32F means values from -PI to +PI. More... | |
static const int | ANGLE_64F = 64 |
Static const variable used to define the source format of a gradient image as atan2(dy, dx) of the edge The format ANGLE_64F means values from -PI to +PI. More... | |
static const int | ANGLE_8U = 8 |
Static const variable used to define the source format of a gradient image as atan2(dy, dx) of the edge The format ANGLE_8U means zero rad are 0, +PI and -PI are 0x7F. More... | |
static const int | MODE_COMPLEX = 4 |
Static const variable used to define the methode used to find the contour (linked edges) More... | |
static const int | MODE_CONTOUR = 2 |
Static const variable used to define the methode used to find the contour (linked edges) More... | |
static const int | MODE_GRAIDENT = 3 |
Static const variable used to define the methode used to find the contour (linked edges) More... | |
static const int | MODE_SIMPLE = 1 |
Static const variable used to define the methode used to find the contour (linked edges) More... | |
Private Member Functions | |
void | AllocateMemory () |
int | GetImgDirectionIndex (CvPoint tPoint) |
unsigned char * | getImgEdge (CvPoint tPoint) |
bool | isInImage (const CvPoint &p) |
void | Linking_Complex () |
void | Linking_Contour () |
void | Linking_Gradient () |
void | Linking_Simple () |
void | markNeighborEdgesAsProcessed (unsigned char *pPix) |
void | RelaseMemory () |
void | SumArrayMatrix (int *pMatrixA, int *pMatrixB, int *pSum, const int iSize) |
void | Trace_Complex (CvPoint tPoint, int *pEnd, unsigned int iCommingFromEdge) |
void | Trace_Contour (CvPoint tPoint, int *pEnd, unsigned int iCommingFromEdge) |
void | Trace_Gradient (CvPoint tPoint, int *pEnd) |
void | Trace_Simple (CvPoint tPoint, int *pEnd) |
Static Private Member Functions | |
static const CvPoint | GetNeighborPoint (CvPoint pPtrCenter, int iNeighborIndex) |
static const void | SortArrayIndexes (int *pArray, int *pIndexes, const int iSize) |
Private Attributes | |
std::vector< unsigned char > | mAngle8Bit |
bool | mbAllowToModifyTheSources |
int | mdefEdgeLinkMode |
int | mdImgEdgeDirectionType |
unsigned char | mEdgeInProcess |
unsigned char | mEdgeProcessed |
std::vector< CvPoint > | mEdges |
unsigned char | mEdgeToProcess |
int | mImgHeight |
int | mImgWidth |
unsigned int | mNrOfEdges |
unsigned char * | mpImgEdge |
void * | mpImgEdgeDirection |
std::vector< cv::Range > | mSegments |
Static Private Attributes | |
static const double | dPi = 3.1415926535897932384626433832795 |
static const float | fPi = 3.1415926535897932384626433832795 |
static const int | ppContourWeightsField [9][9] |
static const int | ppGradientWeightsField [4][9] |
static const int | pppCommingFromEdgeWeightsField [9][3][3] |
static const int | pppDirectionWeightsField [4][3][3] |
Class to link detected images edges a typical source can be a cvCanny image.
tuw::Contour::Contour | ( | ) |
Definition at line 107 of file contour.cpp.
tuw::Contour::~Contour | ( | ) |
Definition at line 118 of file contour.cpp.
|
private |
Definition at line 122 of file contour.cpp.
void tuw::Contour::Draw | ( | unsigned char * | pImgRGB | ) |
Draws the detected contours in a RGB image with radom colours.
pImgRGB | target image |
Definition at line 163 of file contour.cpp.
void tuw::Contour::GetAbnormitiesInEdgesImage | ( | IplImage * | ptImgEdge, |
std::vector< CvPoint > * | pAbnormities, | ||
uchar | iEdgeStrength = 0 |
||
) |
Find egde contour Abnormities in edge image.
Definition at line 680 of file contour.cpp.
int tuw::Contour::getContours | ( | std::vector< std::vector< cv::Point > > & | contours, |
unsigned | min_length = 0 |
||
) |
Returns the contour as vector of vector points.
contours | |
min_length | on zero all controus are returned |
Definition at line 147 of file contour.cpp.
int tuw::Contour::GetEdgeListSplittedXY | ( | std::vector< cv::Point_< int > > & | rEdges, |
std::vector< unsigned char > ** | ppAngle8Bit = NULL |
||
) |
Returns number of edges and edges in the arguments.
listX | |
listY |
Definition at line 648 of file contour.cpp.
|
private |
Definition at line 193 of file contour.cpp.
|
inlineprivate |
|
staticprivate |
Definition at line 607 of file contour.cpp.
|
inline |
std::vector< cv::Range > tuw::Contour::getSegmentIndexes | ( | ) |
void tuw::Contour::Init | ( | unsigned int | iImgWidth, |
unsigned int | iImgHeight, | ||
bool | bAllowToModifyTheSources = false , |
||
unsigned char | iEdgeToProcess = 0xFF , |
||
unsigned char | iEdgeInProcess = 0xFF-1 , |
||
unsigned char | iEdgeProcessed = 0xFF-2 , |
||
unsigned char | iEdgeStrengthRemoved = 0 |
||
) |
Inititalized the class and reserves the momory needed.
iImgWidth | image width |
iImgHeight | image hight |
bAllowToModifyTheSources | if it is true it will write into your source image based on the parameters iEdgeStrengthSrc and iEdgeStrengthDes, it it it false it will make a copy of the image first (solwer) |
iEdgeToProcess | the strength of an edge in the source image, only of interrest if bAllowToModifyTheSources = true |
iEdgeInProcess | the strength of an edge in process, only of interrest if bAllowToModifyTheSources = true |
iEdgeProcessed | the strength of an edge after it was processed, only of interrest if bAllowToModifyTheSources = true |
iEdgeStrengthRemoved | the strength of an edge whenn it was removed, only of interrest if bAllowToModifyTheSources = true |
Definition at line 178 of file contour.cpp.
|
inlineprivate |
|
private |
Definition at line 544 of file contour.cpp.
|
private |
Definition at line 401 of file contour.cpp.
|
private |
Definition at line 487 of file contour.cpp.
|
private |
Definition at line 271 of file contour.cpp.
|
inlineprivate |
void tuw::Contour::Perform | ( | unsigned char * | pImgEdgeStrength, |
int | defEdgeLinkMode = MODE_CONTOUR , |
||
void * | pImgEdgeDirection = NULL , |
||
int | defImgEdgeDirectionType = ANGLE_8U |
||
) |
Starts the edge linking with a certain mode.
pImgEdgeStrength | edge image, where the edge must be at least of the iEdgeStrengthSrc defined in Contour::Init |
defEdgeLinkMode | defines the used mode to link the edges the default is MODE_CONTOUR MODE_SIMPLE the linker follows the first detected neighbor and removes the others. It checks first the top left and goes than to the right and then the next row (pImgEdgeDirection and defImgEdgeDirectionType are not needed) MODE_CONTOUR the linker follows the first detected neighbor detected on the obosite site from which it steped to the current edge and removes the others. (pImgEdgeDirection and defImgEdgeDirectionType are not needed) MODE_GRAIDENT the linker follows the first detected neighbor detected given by the edge direction in the pImgEdgeDirection image. (pImgEdgeDirection is needed and defImgEdgeDirectionType only if the format of pImgEdgeDirection is unlike ANGLE_8U) MODE_COMPLEX mixes the modes MODE_GRAIDENT and MODE_CONTOUR |
pImgEdgeDirection | pointer to the edge direction image with the angle information of every edge in the pImgEdgeStrength |
defImgEdgeDirectionType | type of the pImgEdgeDirection default is ANGLE_8U. ANGLE_8U the angle values in pImgEdgeDirection are encoded as 8 bit values where zero rad are 0, +PI and -PI are 0x7F. "unsigned char i8BitAngle = (unsigned char) (dRad * 255.0 / (2 * CV_PI) + 128.5);" is a way to generate such information. ANGLE_32F the angle values in pImgEdgeDirection are encoded 32 float value where the ange is defined as atan2(dy, dx) of the related edge in pImgEdgeStrength ANGLE_64F the angle values in pImgEdgeDirection are encoded 32 float value where the ange is defined as atan2(dy, dx) of the related edge in pImgEdgeStrength |
Definition at line 235 of file contour.cpp.
|
private |
Definition at line 132 of file contour.cpp.
|
staticprivate |
Definition at line 660 of file contour.cpp.
|
inlineprivate |
|
private |
Definition at line 562 of file contour.cpp.
|
private |
Definition at line 419 of file contour.cpp.
|
private |
Definition at line 505 of file contour.cpp.
|
private |
Definition at line 323 of file contour.cpp.
|
static |
|
static |
|
static |
|
staticprivate |
|
staticprivate |
|
private |
|
static |
|
static |
|
static |
|
static |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |