/// <summary> /// Este metodo realiza la descomposicion de la imagen descomponiendola por /// los bordes de los huecos presentes en la proyeccion. /// Distintas implementaciones difieren en si se eliminan alguno de estos huecos /// de forma que se agrupan ciertas subimagenes para ser tratadas como una sola. /// </summary> /// <param name="image">La imagen que deseamos descomponer.</param> /// <returns> /// Un array con las distintas partes en que hemos descompuesto /// la imagen de entrada. /// </returns> public override List <MathTextBitmap> Segment(MathTextBitmap image) { //Creamos la proyeccion BitmapProjection proj = BitmapProjection.CreateProjection(mode, image); List <Hole> holes = proj.Holes; //Aqui decidimos a partir de que tamao de hueco vamos a cortar la imagen int threshold = GetImageCutThreshold(holes); //Eliminamos los huecos que tengan menor tamaño que el umbral int i = 1; while (i < holes.Count - 1) { if (((Hole)holes[i]).Size < threshold) { holes.Remove(holes[i]); } else { i++; } } return(ImageCut(image, holes)); }
/// <summary> /// Creates a bitmap out of a projection /// </summary> /// <param name="projection"> /// The projection <see cref="BitmapProjection"/> /// </param> /// <returns> /// A <see cref="Pixbuf"/> with the projection graphical representation. /// </returns> public static Pixbuf CreateProjectionBitmap(BitmapProjection projection) { int max = -1; foreach (int i in projection.Values) { if (max < i) { max = i; } } FloatBitmap bitmap = new FloatBitmap(projection.Values.Length, max); for (int k = 0; k < projection.Values.Length; k++) { Console.WriteLine(projection.Values[k]); for (int j = 0; j < projection.Values[k]; j++) { bitmap[k, j] = FloatBitmap.Black; } } return(bitmap.CreatePixbuf()); }