static gboolean button_pressed(int x, int y) { if (menu_on && menubg && x < menubg->w && y < menubg->h) { if (handle_menu(x, y)) refresh_window(); return TRUE; } if (menuicon && x < menuicon->w && y < menuicon->h) { menu_on = TRUE; refresh_window(); return TRUE; } int t = find_box(x, y); if (t < 0) return FALSE; int tatami = point_click_areas[t].tatami; last_wins[tatami-1].cat = match_list[tatami-1][0].category; last_wins[tatami-1].num = match_list[tatami-1][0].number; refresh_window(); return TRUE; }
PRIVATE VOID sel_palette(int blocks, int distinct, struct rgb *my_color_pt) { int boxes; /* int i, j; */ struct box *ptr; init(blocks, distinct, my_color_pt); /* split box into smaller boxes with about equal number of points */ for (boxes = 1; boxes < PALSIZE; boxes++) { /* ptr=frontier->right; j = 0; while (ptr != NULL) { printf("Box %d, distinct %d, total %d\n",j,ptr->nmbr_distinct, ptr->nmbr_pts); for (i=0; i<ptr->nmbr_distinct; i++) printf("pt %d: %d %d %d",i,distinct_pt[ptr->pts[i]].c[RED], distinct_pt[ptr->pts[i]].c[GREEN], distinct_pt[ptr->pts[i]].c[BLUE]); j++; ptr = ptr->right; } */ ptr = find_box(); split_box(ptr); } assign_color(); }
//now test that element against in its box int test_element_in_box (int i, int j, int ele) { int a, b; find_box (i, j); // printf ("%d %d %d %d", m,p,n,q); for (a = m; a <= p; a++) for (b = n; b <= q; q++) if (mat [a][b] == ele) return -1; return 0; }
void find_center_line(IplImage *blocks, int zoom, CvPoint *best_left, CvPoint *best_right, IplImage *debug) { int longer = blocks->width > blocks->height ? blocks->width : blocks->height; CvSize border_size = cvSize(2 * longer, 2 * longer); IplImage *blocks_border = cvCreateImage(border_size, IPL_DEPTH_8U, 3); CvPoint offset = cvPoint((blocks_border->width - blocks->width) / 2, (blocks_border->height - blocks->height) / 2); cvCopyMakeBorder(blocks, blocks_border, offset, IPL_BORDER_CONSTANT, cvScalarAll(0)); CvPoint left; CvPoint right; int quality; int best_quality = 0; int best_dir16 = 0; for (int dir16 = 0; dir16 < 8; dir16++) { find_box(blocks_border, offset, zoom, dir16, &left, &right, &quality, debug); if (quality > best_quality) { best_quality = quality; best_dir16 = dir16; if (left.x <= right.x) { *best_left = left; *best_right = right; } else { *best_left = right; *best_right = left; } } } cvReleaseImage(&blocks_border); if (debug) cvLine(debug, *best_left, *best_right, cvScalar(255, 0, 0, 255), 3, 8, 0); }