资源简介

基于著名的大津阈值(Otsu Thresholding)法实现的自适应阈值分割程序,C#写的,导入VS项目中直接运行可见效果。

资源截图

代码片段和文件信息

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

namespace OtsuThreshold
{
    public partial class Form1 : Form
    {
        private Otsu ot = new Otsu();
        private Bitmap org;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = Bitmap.FromFile(openFileDialog1.FileName);
                org = (Bitmap)pictureBox1.Image.Clone();
            }
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(saveFileDialog1.FileName);
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            Bitmap temp = (Bitmap)org.Clone();
            ot.Convert2GrayScaleFast(temp);
            int otsuThreshold= ot.getOtsuThreshold((Bitmap)temp);
            ot.threshold(tempotsuThreshold);
            textBox1.Text = otsuThreshold.ToString();
            pictureBox1.Image = temp;
        }

        private void Form1_Load(object sender EventArgs e)
        {
            org = (Bitmap)pictureBox1.Image.Clone();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-07-21 03:09  OtsuThreshold\
     目录           0  2009-07-20 07:03  OtsuThreshold\OtsuThreshold\
     目录           0  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\bin\
     目录           0  2009-07-21 03:21  OtsuThreshold\OtsuThreshold\bin\Debug\
     文件      146944  2009-07-21 06:51  OtsuThreshold\OtsuThreshold\bin\Debug\OtsuThreshold.exe
     文件       14328  2009-07-21 03:54  OtsuThreshold\OtsuThreshold\bin\Debug\OtsuThreshold.vshost.exe
     文件         490  2007-07-21 01:33  OtsuThreshold\OtsuThreshold\bin\Debug\OtsuThreshold.vshost.exe.manifest
     文件        1534  2009-07-20 07:03  OtsuThreshold\OtsuThreshold\Form1.cs
     文件        5836  2009-07-20 07:03  OtsuThreshold\OtsuThreshold\Form1.Designer.cs
     文件      207751  2009-07-20 07:03  OtsuThreshold\OtsuThreshold\Form1.resx
     文件        4896  2009-07-20 07:03  OtsuThreshold\OtsuThreshold\Otsu.cs
     文件        3821  2009-07-21 03:21  OtsuThreshold\OtsuThreshold\OtsuThreshold.csproj
     文件         505  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Program.cs
     目录           0  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\
     文件        1456  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\AssemblyInfo.cs
     文件        2855  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\Resources.Designer.cs
     文件        5612  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\Resources.resx
     文件        1098  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\Settings.Designer.cs
     文件         249  2009-07-21 03:09  OtsuThreshold\OtsuThreshold\Properties\Settings.settings
     文件         929  2009-07-21 03:09  OtsuThreshold\OtsuThreshold.sln

评论

共有 条评论