Esempio n. 1
1
                /// <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)
                {
                        Dilation dilation = new Dilation (this.se);
                        Erosion erosion = new Erosion (this.se);

                        return (erosion.Execute (dilation.Execute (src)));
                }
Esempio n. 2
0
        private static void DemoDilation()
        {
            StructuringElement se  = StructuringElement.CreateSquare(3);
            Dilation           dil = new Dilation(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       = dil.Execute(thres_matrix);

                    string dest = string.Format("dilation/{0}.txt", line);
                    using (StreamWriter sw = new StreamWriter(dest, false))
                    {
                        sw.Write(result.ToString());
                    }
                    result.ToBitmap().Save(string.Format("dilation/{0}.png", line));
                }
            }
        }
Esempio n. 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)
        {
            Dilation dilation = new Dilation(this.se);
            Erosion  erosion  = new Erosion(this.se);

            return(erosion.Execute(dilation.Execute(src)));
        }
Esempio n. 4
0
                private static void DemoDilation()
                {
                        StructuringElement se = StructuringElement.CreateSquare(3);
                        Dilation dil = new Dilation(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 = dil.Execute(thres_matrix);

                                        string dest = string.Format("dilation/{0}.txt", line);
                                        using (StreamWriter sw = new StreamWriter(dest, false))
                                        {
                                                sw.Write(result.ToString());
                                        }
                                        result.ToBitmap().Save(string.Format("dilation/{0}.png", line));
                                }
                        }

                }