58 int pix_height = pixGetHeight(pix);
60 int width = box.
width();
62 Box* blob_pix_box = boxCreate(box.
left(), pix_height - box.
top(),
64 Pix* pix_blob = pixClipRectangle(pix, blob_pix_box,
NULL);
65 boxDestroy(&blob_pix_box);
66 Pix* dist_pix = pixDistanceFunction(pix_blob, 4, 8, L_BOUNDARY_BG);
67 pixDestroy(&pix_blob);
69 uinT32* data = pixGetData(dist_pix);
70 int wpl = pixGetWpl(dist_pix);
72 STATS h_stats(0, width + 1);
73 for (
int y = 0; y < height; ++y) {
74 uinT32* pixels = data + y*wpl;
76 int pixel = GET_DATA_BYTE(pixels, 0);
77 for (
int x = 1; x < width; ++x) {
78 int next_pixel = GET_DATA_BYTE(pixels, x);
81 if (prev_pixel < pixel &&
82 (y == 0 || pixel == GET_DATA_BYTE(pixels - wpl, x - 1)) &&
83 (y == height - 1 || pixel == GET_DATA_BYTE(pixels + wpl, x - 1))) {
84 if (pixel > next_pixel) {
86 h_stats.add(pixel * 2 - 1, 1);
87 }
else if (pixel == next_pixel && x + 1 < width &&
88 pixel > GET_DATA_BYTE(pixels, x + 1)) {
90 h_stats.add(pixel * 2, 1);
98 STATS v_stats(0, height + 1);
99 for (
int x = 0; x < width; ++x) {
101 int pixel = GET_DATA_BYTE(data, x);
102 for (
int y = 1; y < height; ++y) {
103 uinT32* pixels = data + y*wpl;
104 int next_pixel = GET_DATA_BYTE(pixels, x);
107 if (prev_pixel < pixel &&
108 (x == 0 || pixel == GET_DATA_BYTE(pixels - wpl, x - 1)) &&
109 (x == width - 1 || pixel == GET_DATA_BYTE(pixels - wpl, x + 1))) {
110 if (pixel > next_pixel) {
112 v_stats.add(pixel * 2 - 1, 1);
113 }
else if (pixel == next_pixel && y + 1 < height &&
114 pixel > GET_DATA_BYTE(pixels + wpl, x)) {
116 v_stats.add(pixel * 2, 1);
123 pixDestroy(&dist_pix);
130 if (h_stats.get_total() >= (width + height) / 4) {
132 if (v_stats.get_total() >= (width + height) / 4)
137 if (v_stats.get_total() >= (width + height) / 4 ||
138 v_stats.get_total() > h_stats.get_total()) {
const TBOX & bounding_box() const
void set_vert_stroke_width(float width)
void set_horz_stroke_width(float width)