Esempio n. 1
0
        public override bool Apply(FloatBitmap image)
        {
            int x1, y1, x2, y2;

            try
            {
                ImageBoxerHelper.BoxImage(image, out x1, out y1, out x2, out y2);
            } catch (ApplicationException)
            {
                return(false);
            }

            int width  = (x2 - x1 + 1);
            int height = (y2 - y1 + 1);

            int tolerance = (int)(image.Width * epsilon);

            return(height >= 2 * width + tolerance);
        }
Esempio n. 2
0
        /// <summary>
        /// En este metodo se realiza el recuadre de la imagen.
        /// </summary>
        /// <param name="image">
        /// La matriz bidimensional que contiene la imagen que deseamos
        /// recuadrar.
        /// </param>
        /// <returns>
        /// Una matriz bisimensional con la imagen recuadrada.
        /// </returns>
        public override FloatBitmap Apply(FloatBitmap image)
        {
            // Coordenadas del menor rectangulo que contiene la imagen
            int x1, x2, y1, y2;

            try
            {
                ImageBoxerHelper.BoxImage(image, out x1, out y1, out x2, out y2);
            }
            catch (ApplicationException)
            {
                return(image);
            }

            // Numero de filas o columnas a añadir
            int relleno;

            int height = y2 - y1 + 1;
            int width  = x2 - x1 + 1;

            FloatBitmap framedImage = null;

            if (height >= width)
            {
                relleno     = (height - width);
                framedImage =
                    CreateNewImageColumns(image, relleno, y1, x1, height, width);
            }
            else
            {
                relleno     = (width - height);
                framedImage = CreateNewImageRows(image, relleno,
                                                 y1, x1,
                                                 height, width);
            }

            return(framedImage);
        }