private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { List <Spot> spots = detector.DetectBlobs(); for (int i = 0; i < spots.Count; i++) { spots[i].Image.Save($"D:\\Blobs\\{i}.png", ImageFormat.Png); } }
public BlobDetailsForm(BlobDetector detector) { InitializeComponent(); this.detector = detector; blobsDGV.RowTemplate.Height = 50; foreach (Spot spot in detector.DetectBlobs()) { Bitmap image = spot.Image; blobsDGV.Rows.Add(image, spot.PixelArea); blobsDGV.Rows[blobsDGV.RowCount - 1].Cells[0].Style.BackColor = Color.Black; } blobsDGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; }
public bool DetectPupil(Image <Gray, byte> inputImage, TrackData trackData) { foundPupil = false; var initialLocation = new GTPoint(inputImage.Width / 2, inputImage.Height / 2); if (eye == EyeEnum.Left) { PupilGrayLevel = Settings.Instance.Processing.PupilThresholdLeft; } else { PupilGrayLevel = Settings.Instance.Processing.PupilThresholdRight; } MinPupilSize = Settings.Instance.Processing.PupilSizeMinimum; MaxPupilSize = Settings.Instance.Processing.PupilSizeMaximum; var min = (int)Math.Round(Math.PI * Math.Pow(MinPupilSize, 2)); var max = (int)Math.Round(Math.PI * Math.Pow(MaxPupilSize, 2)); Blobs blobs = blobDetector.DetectBlobs(inputImage, PupilGrayLevel, min, max, false); #region Autotuning data store if (eye == EyeEnum.Left) { trackData.UnfilteredBlobCountLeft = blobs.Count; trackData.UnfilteredTotalBlobAreaLeft = blobs.TotalArea; } else { trackData.UnfilteredBlobCountRight = blobs.Count; trackData.UnfilteredTotalBlobAreaRight = blobs.TotalArea; } #endregion //if (blobDetector.IsFiltering == false) // blobs.FilterByArea(10, (int)blobs.TotalArea); //Console.WriteLine("Average fullness: {0}", blobs.AverageFullness); blobs.EliminateExteriorBlobs(); if (blobDetector.IsFiltering == false) { blobs.FilterByArea(min, max); } if (blobs.Count > 1) { blobs.FilterByDistance(initialLocation); } // New, filter by fullness //blobs.FilterByFullness(0.40); if (blobs.Count > 0) { //blobDetector.blobCounter.ExtractBlobsImage(inputImage.ToBitmap(), blobs.BlobDir.ElementAt(0).Value, false); pupilData.Blob = blobs.BlobDir.ElementAt(0).Value; if (pupilData.Blob != null) { foundPupil = true; pupilData.Center = new GTPoint(pupilData.Blob.CenterOfGravity.X, pupilData.Blob.CenterOfGravity.Y); // We save the values of the gray level in the corners of rectangle around the pupil blob (which are on the iris) // Javier, the array on EmguGray is [y,x] not [x,y] int x = pupilData.Blob.Rectangle.X; int y = pupilData.Blob.Rectangle.Y; int w = pupilData.Blob.Rectangle.Width; int h = pupilData.Blob.Rectangle.Height; pupilData.GrayCorners[0] = (int)inputImage[y, x].Intensity; pupilData.GrayCorners[1] = (int)inputImage[y, x + w - 1].Intensity; pupilData.GrayCorners[2] = (int)inputImage[y + h - 1, x].Intensity; pupilData.GrayCorners[3] = (int)inputImage[y + h - 1, x + w - 1].Intensity; } } else { foundPupil = false; } return(foundPupil); }