private void Adaptive_Filter_Process() { var filter = new AdaptiveSmoothing(); AddLog("filtr AdaptiveSmoothing na " + _view.CurrentFile); filter.ApplyInPlace(_image); Thread.Sleep(200); }
private void Adaptive_Filter_Process(object callback) { var filter = new AdaptiveSmoothing(); AddLog("filtr AdaptiveSmoothing na " + _view.CurrentFile); filter.ApplyInPlace(_image); Thread.Sleep(200); ((AutoResetEvent)callback).Set(); }
public static Bitmap AdaptiveSmoothing(Bitmap bmp) { // create filter AdaptiveSmoothing filter = new AdaptiveSmoothing(); // apply the filter filter.ApplyInPlace(bmp); return(bmp); }
/*---correction preview---*/ private UnmanagedImage previewCorrection(int imgID) { orginalImage = UnmanagedImage.FromManagedImage((Bitmap)System.Drawing.Image.FromFile(examImages[imgID])); grayImage = UnmanagedImage.Create(orginalImage.Width, orginalImage.Height, PixelFormat.Format8bppIndexed); //bright into gray Grayscale.CommonAlgorithms.BT709.Apply(brightnessFilter.Apply(orginalImage), grayImage); //invert invertFilter.ApplyInPlace(grayImage); // create rotation filter RotateBilinear rotationFilter = new RotateBilinear(-skewChecker.GetSkewAngle(grayImage)); rotationFilter.FillColor = Color.Black; //rotationFilter.KeepSize = true; // rotate filter grayImage = rotationFilter.Apply(grayImage); //smooth smoothFilter.ApplyInPlace(grayImage); //threshold thresholdFilter.ApplyInPlace(grayImage); //size filter blobFilter.CoupledSizeFiltering = true; blobFilter.MinWidth = minBlobWidth; blobFilter.MinHeight = minBlobHeight; blobFilter.ApplyInPlace(grayImage); //shape filter blobCounter.ProcessImage(grayImage); Blob[] blobs = blobCounter.GetObjectsInformation(); circleBlobs = new List <Blob>(); int anchorLeft = 0; int anchorRight = 0; Bitmap detactFilter = new Bitmap(grayImage.ToManagedImage()); Graphics graphics = Graphics.FromImage(detactFilter); List <IntPoint> edgePoints; AForge.Point center; float radius; for (int i = 0; i < blobs.Length; i++) { edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]); // is circle if (shapeChecker.IsCircle(edgePoints, out center, out radius)) { circleBlobs.Add(blobs[i]); graphics.DrawEllipse(bluePen, (float)(center.X - radius), (float)(center.Y - radius), (float)(radius * 2), (float)(radius * 2)); //is answerd? if (blobs[i].Fullness > fullnessAvg) { graphics.DrawEllipse(greenPen, (float)(center.X - radius), (float)(center.Y - radius), (float)(radius * 2), (float)(radius * 2)); //understand comulmn limits for (int d = 4; d >= 1; d--) { if (blobs[i].Rectangle.X < grayImage.Width / 4 * d) { anchorRight = grayImage.Width / 4 * d; anchorLeft = (grayImage.Width / 4 * d) - grayImage.Width / 4; } } for (int j = i + 1; j < blobs.Length; j++) { if (blobs[j].Fullness > fullnessAvg && Math.Abs(blobs[i].Rectangle.Y - blobs[j].Rectangle.Y) < yMinDis && blobs[j].Rectangle.X <anchorRight && blobs[j].Rectangle.X> anchorLeft) { graphics.DrawEllipse(yellowPen, (float)(center.X - radius), (float)(center.Y - radius), (float)(radius * 2), (float)(radius * 2)); } } } //end of is answerd } //end of is cricle } //end of for return(grayImage); }