535
535
for (y = 0; y < h; y++) /* check rows from (0,y) */
536
536
error += check_rowcol(state, y*w, 1, w, flags);
538
/* mark (all) white regions as an error if there is more than one.
539
* may want to make this less in-your-face (by only marking
540
* the smallest region as an error, for example -- but what if we
541
* have two regions of identical size?) */
542
for (i = 0; i < state->n; i++) {
543
if (!(state->flags[i] & F_BLACK) &&
544
dsf_size(dsf, i) < nwhite) {
546
if (flags & CC_MARK_ERRORS)
547
state->flags[i] |= F_ERROR;
538
/* If there's more than one white region, pick the largest one to
539
* be the canonical one (arbitrarily tie-breaking towards lower
540
* array indices), and mark all the others as erroneous. */
542
int largest = 0, canonical = -1;
543
for (i = 0; i < state->n; i++)
544
if (!(state->flags[i] & F_BLACK)) {
545
int size = dsf_size(dsf, i);
546
if (largest < size) {
552
if (largest < nwhite) {
553
for (i = 0; i < state->n; i++)
554
if (!(state->flags[i] & F_BLACK) &&
555
dsf_canonify(dsf, i) != canonical) {
557
if (flags & CC_MARK_ERRORS)
558
state->flags[i] |= F_ERROR;