コード例 #1
0
        private void MenuHistogramBalance_Click(object sender, EventArgs e)
        {
            if (!CheckImage()) return;

            try {
                basicProcessor.HistEqual();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "直方图均衡", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            afterImage.Image = basicProcessor.Image;

            // 显示直方图
            BasicTransform temp = new BasicTransform(curBitmap);
            temp.GetHistogram();
            basicProcessor.GetHistogram();

            FormHistogram histoForm = new FormHistogram(temp.Histogram, basicProcessor.Histogram);
            histoForm.Owner = this;
            histoForm.ShowDialog();
        }
コード例 #2
0
        private void MenuOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "图像文件(*.bmp;*.jpg;*gif;*png;*.tif;*.wmf)|"
                        + "*.bmp;*jpg;*gif;*png;*.tif;*.wmf";
            if (open.ShowDialog() == DialogResult.OK)
            {

                try
                {
                    curBitmap = (Bitmap)Image.FromFile(open.FileName);
                }
                catch (Exception exp) { MessageBox.Show(exp.Message); }

                originImage.Refresh();
                originImage.Image = curBitmap;
                p1 = (Bitmap)curBitmap.Clone();
                p2 = (Bitmap)curBitmap.Clone();

                basicProcessor = new BasicTransform(p1);
                ench = new Enhancement(p2);
            }
        }