謝謝你的時間及回覆.
我找到了一比EdgeDetection 更好的方法, 就是用LineRemove 作為偵測線條, 代碼如下:
- using Leadtools;
- using Leadtools.Codecs;
- using Leadtools.ImageProcessing.Core;
- [TestMethod]
- public void ImageRegionPropertyExample()
- {
- // Load an image
- RasterCodecs codecs = new RasterCodecs();
- codecs.ThrowExceptionsOnInvalidImages = true;
- RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Clean.tif"));
- // Prepare the command
- LineRemoveCommand command = new LineRemoveCommand();
- command.LineRemove += new EventHandler<LineRemoveCommandEventArgs>(LineRemoveEvent_S3);
- command.Type = LineRemoveCommandType.Horizontal;
- command.Flags = LineRemoveCommandFlags.UseVariance | LineRemoveCommandFlags.SingleRegion ;
- command.GapLength = 2;
- command.MaximumLineWidth = 5;
- command.MinimumLineLength = 200;
- command.MaximumWallPercent = 10;
- command.Wall = 7;
- command.Variance = 2;
- command.Run(image);
- }
- private void LineRemoveEvent_S3(object sender, LineRemoveCommandEventArgs e)
- {
- MessageBox.Show("Row Col " + "( " + e.StartRow.ToString() + ", " + e.StartColumn + " )" +
- "\n Length " + e.Length.ToString());
- e.Status= RemoveStatus.Remove;
- }
- static class LEAD_VARS
- {
- public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
- }
复制代码
MC |