Пример #1
0
        private static void DemoClosing()
        {
            StructuringElement se      = StructuringElement.CreateLine(3);
            Closing            closing = new Closing(se);

            using (StreamReader sr = new StreamReader("img.txt"))
            {
                String line;

                while ((line = sr.ReadLine()) != null)
                {
                    string source = string.Format("grayscale_img/{0}.jpg", line);
                    Bitmap bmp    = Bitmap.FromFile(source) as Bitmap;

                    Matrix img_matrix = Matrix.FromBitmap(bmp);
                    //Matrix thres_matrix = img_matrix < 100;
                    Matrix result = closing.Execute(img_matrix);

                    string dest = string.Format("closing/{0}.txt", line);
                    using (StreamWriter sw = new StreamWriter(dest, false))
                    {
                        sw.Write(result.ToString());
                    }
                    result.ToBitmap().Save(string.Format("closing/{0}.png", line));
                }
            }
        }
Пример #2
0
                /// <summary>
                /// Performs the <see cref="Closing"/> operator on the given
                /// <see cref="Matrix"/>.
                /// </summary>
                /// <param name="src">
                /// The <see cref="Matrix"/> which should be used by the
                /// operator.
                /// </param>
                /// <returns> The closed <see cref="Matrix"/>. </returns>
                public Matrix Execute (Matrix src)
                {
                        Closing closing = new Closing (this.se);

                        Matrix closed = closing.Execute (src);
                        return (src.isLogical() ? 
                                (closed & (!src)) : (closed - src));
                }
Пример #3
0
        /// <summary>
        /// Performs the <see cref="Closing"/> operator on the given
        /// <see cref="Matrix"/>.
        /// </summary>
        /// <param name="src">
        /// The <see cref="Matrix"/> which should be used by the
        /// operator.
        /// </param>
        /// <returns> The closed <see cref="Matrix"/>. </returns>
        public Matrix Execute(Matrix src)
        {
            Closing closing = new Closing(this.se);

            Matrix closed = closing.Execute(src);

            return(src.isLogical() ?
                   (closed & (!src)) : (closed - src));
        }