00001
00020
00021
00022
00023 #include "plotseg.h"
00024 #include "callcpp.h"
00025 #include "tessclas.h"
00026 #include "blobs.h"
00027 #include "debug.h"
00028 #include "const.h"
00029 #include <math.h>
00030
00031
00032
00033
00034 void *segm_window = NULL;
00035
00038 make_int_var (display_segmentations, 0, make_display_seg,
00039 9, 2, toggle_segmentations, "Display Segmentations");
00042
00043
00044
00045
00049 void display_segmentation(TBLOB *chunks, SEARCH_STATE segmentation) {
00050 void *window;
00051
00052
00053
00054 if (segm_window == NULL) {
00055 segm_window = c_create_window ("Segmentation", 5, 10,
00056 500, 128, -1000.0, 1000.0, 0.0, 256.0);
00057 }
00058 else {
00059 c_clear_window(segm_window);
00060 }
00061
00062 window = segm_window;
00063
00064 render_segmentation(window, chunks, segmentation);
00065
00066 c_make_current(window);
00067 }
00068
00069
00070
00074 void init_plotseg() {
00075 make_display_seg();
00076 }
00077
00078
00079
00084 void render_segmentation(void *window,
00085 TBLOB *chunks,
00086 SEARCH_STATE segmentation) {
00087 TPOINT origin;
00088 TBLOB *blob;
00089 C_COL color = Black;
00090 int char_num = -1;
00091 int chunks_left = 0;
00092
00093 blobs_origin(chunks, &origin);
00094
00095 iterate_blobs(blob, chunks) {
00096
00097 if (chunks_left-- == 0) {
00098 color = color_list[++char_num % NUM_COLORS];
00099
00100 if (char_num < segmentation[0])
00101 chunks_left = segmentation[char_num + 1];
00102 else
00103 chunks_left = MAXINT;
00104 }
00105 render_outline (window, blob->outlines, origin, color);
00106 }
00107 }