【问题标题】:Edge with threshold bar带阈值条的边缘
【发布时间】:2012-10-11 17:48:46
【问题描述】:

我目前正在创建一个程序来操作和更改黑白图像中的像素值。我正在使用 Microsoft Visual Studio 2010。

到目前为止,我已经使用 roberts 梯度创建了边缘检测, 首先,我创建了这个没有用于更改阈值级别的跟踪栏。

当我在跟踪栏中添加以更改阈值时,原始图像会从屏幕上消失。这个想法是让原始图像和处理后的图像并排放置。

【问题讨论】:

  • 您确定是什么代码块导致图像消失。听起来您需要使用调试器来确定,然后再来这里寻求帮助。
  • 我已经调试了很多次,没有错误,从消除过程中我看到的唯一导致问题的区域是private void thresholdBar1_Scroll(object sender, System.EventArgs e) { thresholdValueBox.Visible = true; string thresholdBarVal = Convert.ToString(thresholdBar1.Value); thresholdValueBox.Text = thresholdBarVal; }
  • 任何你用 CreateGraphics() 绘制的东西都会在窗体重新绘制时消失。请改用 Paint 事件。或者使用 PictureBox 控件。

标签: c# visual-studio-2010 edge-detection trackbar


【解决方案1】:

我认为你应该只更新 Form1_Paint 方法。您永远不会在其中绘制 proc_image 。任何重绘都会消除它。

    public void Form1_Paint(object sender, PaintEventArgs e)
    {
        if (original_image != null)
        {
            Graphics g = e.Graphics;
            Rectangle r = new Rectangle(10, 50, original_image.Width, original_image.Height);
            g.DrawImage(original_image, r);


        }
        if(proc_image != null)
        {
            Rectangle r = new Rectangle(535, 50, original_image.Width, original_image.Height);
            e.Graphics.DrawImage(proc_image, r);
        }
    }

【讨论】:

    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 2012-12-31
    • 1970-01-01
    • 1970-01-01
    • 2016-01-08
    • 1970-01-01
    • 1970-01-01
    • 2012-09-22
    相关资源
    最近更新 更多