ConfidenceImage.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using BBIWARG.Utility;
  2. using Emgu.CV;
  3. using Emgu.CV.Structure;
  4. using System;
  5. namespace BBIWARG.Images
  6. {
  7. /// <summary>
  8. /// ConfidenceImage stores the raw confidence data read from the Camera as an <see cref="Image"/>.
  9. /// </summary>
  10. public class ConfidenceImage
  11. {
  12. /// <summary>
  13. /// the confidence image
  14. /// </summary>
  15. public Image<Gray, Int16> Image { get; private set; }
  16. /// <summary>
  17. /// a mask image, which is 1 iff the the confidence value is greater than <see cref="Parameters.ConfidenceImageMinThreshold"/>
  18. /// </summary>
  19. public Image<Gray, byte> Mask { get; private set; }
  20. /// <summary>
  21. /// the size of the confidence image
  22. /// </summary>
  23. public ImageSize Size { get; private set; }
  24. /// <summary>
  25. /// Constructs a new ConfidenceImage using the specified data and size.
  26. /// </summary>
  27. /// <param name="rawConfidenceData">pointer to raw confidence data</param>
  28. /// <param name="size">size of the confidence image</param>
  29. public ConfidenceImage(IntPtr rawConfidenceData, ImageSize size)
  30. {
  31. Size = size;
  32. Image = new Image<Gray, Int16>(Size.Width, Size.Height, size.Width * 2, rawConfidenceData);
  33. Mask = Image.ThresholdBinary(new Gray(Parameters.ConfidenceImageMinThreshold), new Gray(1)).Convert<Gray, byte>();
  34. }
  35. }
  36. }