当前位置:在线查询网 > 在线百科全书查询 > Robert算子

Robert算子_在线百科全书查询


请输入要查询的词条内容:

Robert算子


Roberts边缘检测算子是一种利用局部差分算子寻找边缘的算子,Robert算子图像处理后结果边缘不是很平滑。经分析,由于Robert算子通常会在图像边缘附近的区域内 产生较宽的响应,故采用上述算子检测的边缘图像常需做细化处理,边缘定位的精度不是很高。

.NET代码如下:

private void menuItem23_Click(object sender, System.EventArgs e)

{

if(this.pictureBox1.Image!=null)

{

this.pictureBox2.Visible=true;

int height=this.pictureBox1.Image.Height;

int width=this.pictureBox1.Image.Width;

Bitmap temp=new Bitmap(width,height);

Bitmap process=(Bitmap)this.pictureBox1.Image;

int i,j,p0,p1,p2,p3;

Color [] pixel=new Color[4];

int result;

for(j=height-2;j>0;j--)

{

for(i=0;i<width-2;i++)

{

pixel[0]=process.GetPixel(i,j);

pixel[1]=process.GetPixel(i,j+1);

pixel[2]=process.GetPixel(i+1,j);

pixel[3]=process.GetPixel(i+1,j+1);

p0=(int)(0.3*pixel[0].R+0.59*pixel[0].G+0.11*pixel[0].B);

p1=(int)(0.3*pixel[1].R+0.59*pixel[1].G+0.11*pixel[1].B);

p2=(int)(0.3*pixel[2].R+0.59*pixel[2].G+0.11*pixel[2].B);

p3=(int)(0.3*pixel[3].R+0.59*pixel[3].G+0.11*pixel[3].B);

result=(int)Math.Sqrt((p0-p3)*(p0-p3)+(p1-p2)*(p1-p2));

if (result>255)

result=255;

if (result<0)

result=0;

temp.SetPixel(i,j,Color.FromArgb(result,result,result));

}

}

this.pictureBox2.Image=temp;

}

}

相关分词: Robert 算子