#include "clusttool.h"
#include "emalloc.h"
#include "mfoutline.h"
#include "blobs.h"
#include "const.h"
#include "mfx.h"
#include "params.h"
#include "classify.h"
#include <math.h>
#include <stdio.h>
Go to the source code of this file.
|
| LIST | ConvertBlob (TBLOB *blob) |
| |
| MFOUTLINE | ConvertOutline (TESSLINE *outline) |
| |
| LIST | ConvertOutlines (TESSLINE *outline, LIST mf_outlines, OUTLINETYPE outline_type) |
| |
| void | ComputeOutlineStats (LIST Outlines, OUTLINE_STATS *OutlineStats) |
| |
| void | FindDirectionChanges (MFOUTLINE Outline, FLOAT32 MinSlope, FLOAT32 MaxSlope) |
| |
| void | FreeMFOutline (void *arg) |
| |
| void | FreeOutlines (LIST Outlines) |
| |
| void | MarkDirectionChanges (MFOUTLINE Outline) |
| |
| MFEDGEPT * | NewEdgePoint () |
| |
| MFOUTLINE | NextExtremity (MFOUTLINE EdgePoint) |
| |
| void | NormalizeOutline (MFOUTLINE Outline, FLOAT32 XOrigin) |
| |
| void | ChangeDirection (MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction) |
| |
| void | CharNormalizeOutline (MFOUTLINE Outline, FLOAT32 XCenter, FLOAT32 YCenter, FLOAT32 XScale, FLOAT32 YScale) |
| |
| void | ComputeDirection (MFEDGEPT *Start, MFEDGEPT *Finish, FLOAT32 MinSlope, FLOAT32 MaxSlope) |
| |
| void | FinishOutlineStats (register OUTLINE_STATS *OutlineStats) |
| |
| void | InitOutlineStats (OUTLINE_STATS *OutlineStats) |
| |
| MFOUTLINE | NextDirectionChange (MFOUTLINE EdgePoint) |
| |
| void | UpdateOutlineStats (register OUTLINE_STATS *OutlineStats, register FLOAT32 x1, register FLOAT32 x2, register FLOAT32 y1, register FLOAT32 y2) |
| |
| #define MIN_INERTIA (0.00001) |
Private Code
Definition at line 413 of file mfoutline.cpp.
430 for (Current = Start; Current != End; Current =
NextPointAfter (Current))
431 PointAt (Current)->Direction = Direction;
433 PointAt (End)->PreviousDirection = Direction;
#define NextPointAfter(E)
Definition at line 439 of file mfoutline.cpp.
466 CurrentPoint =
PointAt (Current);
468 (CurrentPoint->
Point.
x - XCenter) * XScale;
470 (CurrentPoint->
Point.
y - YCenter) * YScale;
474 while (Current != First);
#define NextPointAfter(E)
Definition at line 480 of file mfoutline.cpp.
519 Start->
Slope = Delta.
y / Delta.
x;
522 if (Start->
Slope > MinSlope)
523 if (Start->
Slope < MaxSlope)
529 else if (Start->
Slope < -MinSlope)
530 if (Start->
Slope > -MaxSlope)
536 else if (Delta.
y > 0)
537 if (Start->
Slope < -MinSlope)
538 if (Start->
Slope > -MaxSlope)
544 else if (Start->
Slope > MinSlope)
545 if (Start->
Slope < MaxSlope)
DIRECTION PreviousDirection
Definition at line 108 of file mfoutline.cpp.
149 while (EdgePoint != Outline);
void InitOutlineStats(OUTLINE_STATS *OutlineStats)
void UpdateOutlineStats(register OUTLINE_STATS *OutlineStats, register FLOAT32 x1, register FLOAT32 x2, register FLOAT32 y1, register FLOAT32 y2)
#define NextPointAfter(E)
void FinishOutlineStats(register OUTLINE_STATS *OutlineStats)
Definition at line 41 of file mfoutline.cpp.
LIST ConvertOutlines(TESSLINE *outline, LIST mf_outlines, OUTLINETYPE outline_type)
Definition at line 51 of file mfoutline.cpp.
61 StartPoint = outline->
loop;
62 EdgePoint = StartPoint;
64 NextPoint = EdgePoint->
next;
67 if (EdgePoint->
pos.
x != NextPoint->
pos.
x ||
68 EdgePoint->
pos.
y != NextPoint->
pos.
y) {
74 MFOutline =
push(MFOutline, NewPoint);
76 EdgePoint = NextPoint;
77 }
while (EdgePoint != StartPoint);
79 if (MFOutline !=
NULL)
#define MakeOutlineCircular(O)
MFEDGEPT * NewEdgePoint()
LIST push(LIST list, void *element)
Definition at line 92 of file mfoutline.cpp.
97 while (outline !=
NULL) {
99 if (mf_outline !=
NULL)
100 mf_outlines =
push(mf_outlines, mf_outline);
101 outline = outline->
next;
LIST push(LIST list, void *element)
MFOUTLINE ConvertOutline(TESSLINE *outline)
Definition at line 157 of file mfoutline.cpp.
194 while (EdgePoint != Outline);
void ComputeDirection(MFEDGEPT *Start, MFEDGEPT *Finish, FLOAT32 MinSlope, FLOAT32 MaxSlope)
#define DegenerateOutline(O)
#define NextPointAfter(E)
Definition at line 557 of file mfoutline.cpp.
570 OutlineStats->x = 0.5 * OutlineStats->My / OutlineStats->L;
571 OutlineStats->y = 0.5 * OutlineStats->Mx / OutlineStats->L;
573 OutlineStats->Ix = (OutlineStats->Ix / 3.0 -
574 OutlineStats->y * OutlineStats->Mx +
575 OutlineStats->y * OutlineStats->y * OutlineStats->L);
577 OutlineStats->Iy = (OutlineStats->Iy / 3.0 -
578 OutlineStats->x * OutlineStats->My +
579 OutlineStats->x * OutlineStats->x * OutlineStats->L);
582 if (OutlineStats->Ix < 0.0)
584 if (OutlineStats->Iy < 0.0)
587 OutlineStats->Rx = sqrt (OutlineStats->Ix / OutlineStats->L);
588 OutlineStats->Ry = sqrt (OutlineStats->Iy / OutlineStats->L);
590 OutlineStats->Mx *= 0.5;
591 OutlineStats->My *= 0.5;
| void FreeMFOutline |
( |
void * |
arg | ) |
|
Definition at line 200 of file mfoutline.cpp.
218 while (Start !=
NULL) {
void free_struct(void *deadstruct, inT32, const char *)
#define set_rest(l, cell)
| void FreeOutlines |
( |
LIST |
Outlines | ) |
|
Definition at line 227 of file mfoutline.cpp.
void destroy_nodes(LIST list, void_dest destructor)
void FreeMFOutline(void *arg)
Definition at line 597 of file mfoutline.cpp.
608 OutlineStats->
Mx = 0.0;
609 OutlineStats->
My = 0.0;
610 OutlineStats->
L = 0.0;
611 OutlineStats->
x = 0.0;
612 OutlineStats->
y = 0.0;
613 OutlineStats->
Ix = 0.0;
614 OutlineStats->
Iy = 0.0;
615 OutlineStats->
Rx = 0.0;
616 OutlineStats->
Ry = 0.0;
| void MarkDirectionChanges |
( |
MFOUTLINE |
Outline | ) |
|
Definition at line 243 of file mfoutline.cpp.
274 while (Last != First);
#define DegenerateOutline(O)
MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint)
Definition at line 281 of file mfoutline.cpp.
void * alloc_struct(inT32 count, const char *)
Definition at line 621 of file mfoutline.cpp.
637 InitialDirection =
PointAt (EdgePoint)->Direction;
643 }
while (
PointAt(EdgePoint)->Direction == InitialDirection &&
#define NextPointAfter(E)
Definition at line 287 of file mfoutline.cpp.
303 while (!
PointAt(EdgePoint)->ExtremityMark)
#define NextPointAfter(E)
Definition at line 312 of file mfoutline.cpp.
340 }
while (EdgePoint != Outline);
#define NextPointAfter(E)
Definition at line 652 of file mfoutline.cpp.
683 L = sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
684 OutlineStats->L += L;
689 OutlineStats->Mx += Mx2;
690 OutlineStats->My += My2;
693 OutlineStats->Ix += Mx2 * (y1 + y2) - L * y1 * y2;
694 OutlineStats->Iy += My2 * (x1 + x2) - L * x1 * x2;