Mik*_*kos 1 .net edge-detection aforge
我正在使用Aforge对图像进行边缘检测,如何获得检测到的边缘点的x,y?除了循环通过图像位图的明显方式.
这是Aforge样本的代码,但我如何获得边缘点?
// On Filters->Sobel edge detector
private void sobelEdgesFiltersItem_Click( object sender, System.EventArgs e )
{
// save original image
Bitmap originalImage = sourceImage;
// get grayscale image
sourceImage = Grayscale.CommonAlgorithms.RMY.Apply( sourceImage );
// apply edge filter
ApplyFilter( new SobelEdgeDetector( ) );
// delete grayscale image and restore original
sourceImage.Dispose( );
sourceImage = originalImage;
// this is the part where the source image is now edge detected. How to get the x,y for //each point of the edge?
sobelEdgesFiltersItem.Checked = true;
}
Run Code Online (Sandbox Code Playgroud)
过滤器只是顾名思义:过滤器(图像 - >过程 - > NewImage)
我不知道,如果边缘有类似的东西,但AForge有一个角落探测器.我的样本加载图像,运行角点检测器并在每个角落周围显示小红框.(你需要一个名为"pictureBox"的PictureBox控件).
public void DetectCorners()
{
// Load image and create everything you need for drawing
Bitmap image = new Bitmap(@"myimage.jpg");
Graphics graphics = Graphics.FromImage(image);
SolidBrush brush = new SolidBrush(Color.Red);
Pen pen = new Pen(brush);
// Create corner detector and have it process the image
MoravecCornersDetector mcd = new MoravecCornersDetector();
List<IntPoint> corners = mcd.ProcessImage(image);
// Visualization: Draw 3x3 boxes around the corners
foreach (IntPoint corner in corners)
{
graphics.DrawRectangle(pen, corner.X - 1, corner.Y - 1, 3, 3);
}
// Display
pictureBox.Image = image;
}
Run Code Online (Sandbox Code Playgroud)
它可能不是您正在寻找的,但也许它会有所帮助.
| 归档时间: |
|
| 查看次数: |
8016 次 |
| 最近记录: |