/// <summary> /// A valid line segmentation may contain 0 or 0xffffff as the /// background, and otherwise numbers components starting at 1. /// The segmentation consists of segmented background pixels /// (0x80xxxx) and segmented foreground pixels (0x00xxxx). The /// segmented foreground pixels should constitute a usable /// binarization of the original image. /// </summary> public static void check_line_segmentation(Intarray cseg) { if (cseg.Length1d() == 0) { return; } if (cseg.Rank() != 2) { throw new Exception("check_line_segmentation: rank must be 2"); } for (int i = 0; i < cseg.Length1d(); i++) { int value = cseg.At1d(i); if (value == 0) { continue; } if (value == 0xffffff) { continue; } if ((value & 0x800000) > 0) { if ((value & ~0x800000) > 100000) { throw new Exception("check_line_segmentation: (value & ~0x800000) > 100000"); } } else if (value > 100000) { throw new Exception("check_line_segmentation: value > 100000"); } } }