• 大小: 153KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: C#
  • 标签: 腐蚀  膨胀  

资源简介

实现数学形态学对二值图像的各种处理,如腐蚀运算、膨胀运算、开运算、闭运算和击中击不中变换等。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace morphology
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void open_Click(object sender EventArgs e)
        {
            OpenFileDialog opnDlg = new OpenFileDialog();
            opnDlg.Filter = “所有图像文件 | *.bmp; *.pcx; *.png; *.jpg; *.gif;“ +
                “*.tif; *.ico; *.dxf; *.cgm; *.cdr; *.wmf; *.eps; *.emf|“ +
                “位图( *.bmp; *.jpg; *.png;...) | *.bmp; *.pcx; *.png; *.jpg; *.gif; *.tif; *.ico|“ +
                “矢量图( *.wmf; *.eps; *.emf;...) | *.dxf; *.cgm; *.cdr; *.wmf; *.eps; *.emf“;
            opnDlg.title = “打开图像文件“;
            opnDlg.ShowHelp = true;
            if (opnDlg.ShowDialog() == DialogResult.OK)
            {
                curFileName = opnDlg.FileName;
                try
                {
                    curBitmap = (Bitmap)Image.FromFile(curFileName);
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message);
                }
            }
            Invalidate();
        }

        private void close_Click(object sender EventArgs e)
        {
            this.Close();
        }

        private void Form1_Paint(object sender PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            if (curBitmap != null)
            {
                g.DrawImage(curBitmap 160 20 curBitmap.Width curBitmap.Height);
            }
        }

        private void erode_Click(object sender EventArgs e)
        {
            if (curBitmap != null)
            {
                struction struForm = new struction();
                struForm.Text = “腐蚀运算结构元素“;
                if (struForm.ShowDialog() == DialogResult.OK)
                {
                    Rectangle rect = new Rectangle(0 0 curBitmap.Width curBitmap.Height);
                    System.Drawing.Imaging.BitmapData bmpData = curBitmap.LockBits(rect System.Drawing.Imaging.ImageLockMode.ReadWrite curBitmap.PixelFormat);
                    IntPtr ptr = bmpData.Scan0;
                    int bytes = curBitmap.Width * curBitmap.Height;
                    byte[] grayValues = new byte[bytes];
                    System.Runtime.InteropServices.Marshal.Copy(ptr grayValues 0 bytes);

                    byte flagStru = struForm.GetStruction;

                    byte[] tempArray = new byte[bytes];
                    for (int i = 0; i < bytes; i++)
                    {
                        tempArray[i] = 255;
                    }

                    switch (flagStru)
                    {
                        case 0x11:
                            for (int i = 0; i < curBitmap.Height; i++)
                        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      73230  2008-08-20 15:09  morphology\Backup\morphology\Form1.cs

     文件       5886  2008-08-20 15:09  morphology\Backup\morphology\Form1.Designer.cs

     文件       5814  2008-08-20 15:09  morphology\Backup\morphology\Form1.resx

     文件       9787  2008-08-22 15:48  morphology\Backup\morphology\hitmiss.cs

     文件      16595  2008-08-22 15:48  morphology\Backup\morphology\hitmiss.Designer.cs

     文件       5814  2008-08-22 15:48  morphology\Backup\morphology\hitmiss.resx

     文件       3935  2007-12-25 09:04  morphology\Backup\morphology\morphology.csproj

     文件        469  2007-10-10 21:21  morphology\Backup\morphology\Program.cs

     文件       1192  2007-10-10 21:21  morphology\Backup\morphology\Properties\AssemblyInfo.cs

     文件       2875  2007-10-10 21:21  morphology\Backup\morphology\Properties\Resources.Designer.cs

     文件       5612  2007-10-10 21:21  morphology\Backup\morphology\Properties\Resources.resx

     文件       1094  2007-10-10 21:21  morphology\Backup\morphology\Properties\Settings.Designer.cs

     文件        249  2007-10-10 21:21  morphology\Backup\morphology\Properties\Settings.settings

     文件       3427  2008-09-05 10:13  morphology\Backup\morphology\struction.cs

     文件       9623  2008-08-20 10:03  morphology\Backup\morphology\struction.Designer.cs

     文件       5814  2008-08-20 10:03  morphology\Backup\morphology\struction.resx

     文件        919  2007-10-10 21:21  morphology\Backup\morphology.sln

    ..A..H.     22528  2008-09-05 10:27  morphology\Backup\morphology.suo

     文件       4072  2007-11-05 21:23  morphology\morphology\bin\Debug\images\col3.jpg

     文件       5487  2007-11-05 21:23  morphology\morphology\bin\Debug\images\col5.jpg

     文件       5578  2007-11-05 21:21  morphology\morphology\bin\Debug\images\cross3.jpg

     文件       8000  2007-11-05 21:16  morphology\morphology\bin\Debug\images\cross5.jpg

     文件       4090  2007-11-05 21:21  morphology\morphology\bin\Debug\images\row3.jpg

     文件       5501  2007-11-05 21:22  morphology\morphology\bin\Debug\images\row5.jpg

     文件       6667  2007-11-05 21:19  morphology\morphology\bin\Debug\images\square3.jpg

     文件      14003  2007-11-05 21:14  morphology\morphology\bin\Debug\images\square5.jpg

     文件      19968  2007-11-05 21:23  morphology\morphology\bin\Debug\images\Thumbs.db

     文件      42496  2014-07-22 18:45  morphology\morphology\bin\Debug\morphology.exe

     文件      89600  2014-07-22 18:45  morphology\morphology\bin\Debug\morphology.pdb

     文件      14328  2014-12-10 15:05  morphology\morphology\bin\Debug\morphology.vshost.exe

............此处省略52个文件信息

评论

共有 条评论