private void UpdateGapDistance() { RBSK rbsk = MouseService.GetStandardMouseRules(); rbsk.Settings.GapDistance = GapDistance; rbsk.Settings.BinaryThreshold = ThresholdValue; PointF[] result = RBSKService.RBSK(OriginalImage, rbsk); if (result == null || !result.Any()) { DisplayImage = ImageService.ToBitmapSource(OriginalImage); return; } using (Image <Gray, Byte> displayImage = OriginalImage.Convert <Gray, Byte>()) using (Image <Gray, Byte> binaryimage = displayImage.ThresholdBinary(new Gray(ThresholdValue), new Gray(255))) using (Image <Bgr, byte> drawImage = binaryimage.Convert <Bgr, byte>()) { foreach (PointF point in result) { drawImage.Draw(new CircleF(point, 2), new Bgr(Color.Yellow), 2); } DisplayImage = ImageService.ToBitmapSource(drawImage); } PreviewGenerated = false; Boundries = new ObservableCollection <BoundaryBaseViewModel>(); //Console.WriteLine(GapDistance); }
private void ProcessFrame() { using (Image <Gray, Byte> displayImage = OriginalImage.Convert <Gray, Byte>()) using (Image <Gray, Byte> binaryimage = displayImage.ThresholdBinary(new Gray(ThresholdValue), new Gray(255))) { DisplayImage = ImageService.ToBitmapSource(binaryimage); } PreviewGenerated = false; Boundries = new ObservableCollection <BoundaryBaseViewModel>(); }
private void Test() { OriginalImage.Save(@"C:\Users\10488835\Desktop\PhD\Papers\Software Practise and Experience\Latex\images\BackgroundSub\1-Original.png"); using (Image <Gray, Byte> displayImage = OriginalImage.Convert <Gray, Byte>()) using (Image <Gray, Byte> binaryimage = displayImage.ThresholdBinary(new Gray(ThresholdValue), new Gray(255))) { binaryimage.Save(@"C:\Users\10488835\Desktop\PhD\Papers\Software Practise and Experience\Latex\images\BackgroundSub\2-BinaryImage.png"); Image <Gray, Byte> binaryBackground; IEnumerable <IBoundaryBase> boundaries; VideoSettings.GeneratePreview(Video, out binaryBackground, out boundaries); binaryBackground.Save(@"C:\Users\10488835\Desktop\PhD\Papers\Software Practise and Experience\Latex\images\BackgroundSub\3-BinaryBackground.png"); using (Image <Gray, Byte> subbed = binaryBackground.AbsDiff(binaryimage)) using (Image <Gray, Byte> not = binaryBackground.Not()) using (Image <Gray, Byte> added = binaryimage.Add(not)) { added.Save(@"C:\Users\10488835\Desktop\PhD\Papers\Software Practise and Experience\Latex\images\BackgroundSub\4-BinaryAdded.png"); } } }