EdgeImage.cs 928 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Emgu.CV;
  7. using Emgu.CV.Structure;
  8. namespace bbiwarg.Images
  9. {
  10. class EdgeImage
  11. {
  12. private Image<Gray, Byte> image;
  13. public EdgeImage(DepthImage depthImage) {
  14. int minDepth = depthImage.getMinDepth();
  15. int maxDepth = depthImage.getMaxDepth();
  16. Image<Gray, Int16> depthImageInt16 = depthImage.getImage();
  17. Image<Gray, Byte> depthImageByte = depthImageInt16.Convert<Byte>(delegate(Int16 depth) { return (byte)(((depth - minDepth) * Byte.MaxValue) / (maxDepth - minDepth)); });
  18. image = depthImageByte.Canny(100, 75, 3);
  19. }
  20. public bool isEdgeAt(int x, int y) {
  21. return (image.Data[y,x,0] > 0);
  22. }
  23. public Image<Gray, Byte> getImage()
  24. {
  25. return image;
  26. }
  27. }
  28. }