图像边界的提取,怎么用
privatevoidBound_Click(objectsender, EventArgs e) {
if(bitMap !=null)
{
BoundExtract boundExtract =newBoundExtract(bitMap);
boundExtract.Draw();
Invalidate();
}
}
public class BoundExtract:ImageFeature
{
bool bBound; //是否是边界点的判断
public BoundExtract(Bitmap bitmap):base(bitmap)
{
}
/// <summary>
///3X3的边界提取
/// </summary>
public void Extract()
{
for (int j=1;j<h-1;j++)
for (int i = 1; i < w - 1; i++)
{
bBound = false;
if (binary[i, j] == 0) continue;
for(int k=-1;k<=1;k++)
for (int l = -1; l <= 1; l++)
{
if (binary[i + k, j + l] == 0)
{
bBound = true;
k = 2;
l = 2;
}
}
if (!bBound) bitMap.SetPixel(i, j, Color.FromArgb(255, 255, 255));
//不是边界点将其置为白色
}
}
public override void Draw()
{
ToBianry();
Extract();
}
}