public static void combine_segmentations(ref Intarray dst, Intarray src) { dst.SameDims(src); int n = NarrayUtil.Max(dst) + 1; for (int i = 0; i < dst.Length1d(); i++) { dst.Put1d(i, (dst.At1d(i) + src.At1d(i) * n)); } ImgLabels.renumber_labels(dst, 1); }
/// <summary> /// Extract the masked character from the source image/source /// feature map. /// </summary> void extractMasked <T>(Narray <T> outa, Bytearray outmask, Narray <T> source, int index, int grow = 0) { if (!labels.SameDims(source)) { throw new Exception("ASSERT: labels.SameDims(source)"); } Rect r; GetMask(out r, ref outmask, index, grow); int x = r.x0, y = r.y0, w = r.Width(), h = r.Height(); outa.Resize(w, h); outa.Fill(0); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { if (outmask[i, j] > 0) { outa[i, j] = source[i + x, j + y]; } } } }