0
我目前正在创建一个程序,它可以在黑白图像中操作和更改像素值。我正在使用Microsoft Visual Studio 2010.边缘与阈值
到目前为止,我已经使用roberts渐变创建了边缘检测, 首先,我创建了此选项,但没有用于更改阈值级别的轨迹栏。
当我在轨迹栏中添加更改阈值时,原始图像会在屏幕上消失。这个想法是将原始图像和处理后的图像并排放置。
我目前正在创建一个程序,它可以在黑白图像中操作和更改像素值。我正在使用Microsoft Visual Studio 2010.边缘与阈值
到目前为止,我已经使用roberts渐变创建了边缘检测, 首先,我创建了此选项,但没有用于更改阈值级别的轨迹栏。
当我在轨迹栏中添加更改阈值时,原始图像会在屏幕上消失。这个想法是将原始图像和处理后的图像并排放置。
我想你应该只更新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);
}
}
您是否确定代码块导致图像消失。这听起来像你需要使用调试器来确定在你来到这里之前寻求帮助。 –
我已经调试了很多次,没有错误,从一个过程中消除唯一的区域,我可以看到造成一个问题是私人无效thresholdBar1_Scroll(对象发件人,System.EventArgs e) { thresholdValueBox.Visible = true ; string thresholdBarVal = Convert.ToString(thresholdBar1.Value); thresholdValueBox.Text = thresholdBarVal; } ' – user1081326
任何使用CreateGraphics()绘制的东西都会在表单重新绘制时消失。改用Paint事件。或者使用PictureBox控件。 –