static void update(int c) { int i, j, k, l; if (freq[R] == MAX_FREQ) { reconst(); } c = prnt[c + T]; do { k = ++freq[c]; /* if the order is disturbed, exchange nodes */ if ((unsigned)k > freq[l = c + 1]) { while ((unsigned)k > freq[++l]); l--; freq[c] = freq[l]; freq[l] = k; i = son[c]; prnt[i] = l; if (i < T) prnt[i + 1] = l; j = son[l]; son[l] = i; prnt[j] = c; if (j < T) prnt[j + 1] = c; son[c] = j; c = l; } } while ((c = prnt[c]) != 0); /* repeat up to root */ }
INLINE void update(USHORT c){ USHORT i, j, k, l; if (freq[R] == MAX_FREQ) { reconst(); } c = prnt[c + T]; do { k = ++freq[c]; /* if the order is disturbed, exchange nodes */ if (k > freq[l = (USHORT)(c + 1)]) { while (k > freq[++l]); l--; freq[c] = freq[l]; freq[l] = k; i = son[c]; prnt[i] = l; if (i < T) prnt[i + 1] = l; j = son[l]; son[l] = i; prnt[j] = c; if (j < T) prnt[j + 1] = c; son[c] = j; c = l; } } while ((c = prnt[c]) != 0); /* repeat up to root */ }
void td0dsk_t::update(int c) { int i, j, k, l; if (freq[R] == MAX_FREQ) { reconst(); } c = prnt[c + T]; do { k = ++freq[c]; /* swap nodes to keep the tree freq-ordered */ if (k > freq[l = c + 1]) { while (k > freq[++l]); l--; freq[c] = freq[l]; freq[l] = k; i = son[c]; prnt[i] = l; if (i < T) prnt[i + 1] = l; j = son[l]; son[l] = i; prnt[j] = c; if (j < T) prnt[j + 1] = c; son[c] = j; c = l; } } while ((c = prnt[c]) != 0); /* do it until reaching the root */ }
void RegionalMinImage::perform(GreyLevelImage * img) { GreyLevelImage reconst(*img); DilatedImage::perform(img); GeodesicRecEroImage::perform(img, &reconst); *img -= reconst; }
void RegionalMinBinaryImage::perform(BinaryImage * img) { BinaryImage reconst(*img); DilatedBinaryImage::perform(img); GeodesicRecEroBinaryImage::perform(img, &reconst); *img -= reconst; }
/* ------------------------------------------------------------------------ */ static void update_c(int p) { int q; if (freq[ROOT_C] == 0x8000) { reconst(0, n_max * 2 - 1); } freq[ROOT_C]++; q = s_node[p]; do { q = swap_inc(q); } while (q != ROOT_C); }
/* ------------------------------------------------------------------------ */ static void update_p(int p) { int q; if (total_p == 0x8000) { reconst(ROOT_P, most_p + 1); total_p = freq[ROOT_P]; freq[ROOT_P] = 0xffff; } q = s_node[p + N_CHAR]; while (q != ROOT_P) { q = swap_inc(q); } total_p++; }