Guest User

Untitled

a guest
Jun 26th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. template<typename MatType, typename CubeType>
  2. void StructuredForests<MatType, CubeType>::
  3. ConvTriangle2(CubeType& InImage, const size_t radius, CubeType& Output)
  4. {
  5. Timer::Start("ConvTriangle_mlpack");
  6. if (radius != 0)
  7. {
  8. if (radius <= 1)
  9. {
  10. const double p = 12.0 / radius / (radius + 2) - 2;
  11. arma::vec kernel = {1, p, 1};
  12. kernel /= (p + 2);
  13. MatType k_mat = kernel * kernel.t();
  14. mlpack::ann::NaiveConvolution<FullConvolution>::Convolution(InImage, k_mat, Output);
  15. //this->SepFilter2D(InImage, kernel, radius);
  16. }
  17. else
  18. {
  19. const size_t len = 2 * radius + 1;
  20. arma::vec kernel(len);
  21. for( size_t i = 0; i < radius; ++i)
  22. kernel(i) = i + 1;
  23.  
  24. kernel(radius) = radius + 1;
  25.  
  26. size_t r = radius;
  27. for( size_t i = radius + 1; i < len; ++i)
  28. kernel(i) = r--;
  29.  
  30. kernel /= std::pow(radius + 1, 2);
  31. MatType k_mat = kernel * kernel.t();
  32. mlpack::ann::NaiveConvolution<FullConvolution>::Convolution(InImage, k_mat, Output);
  33. //this->SepFilter2D(InImage, kernel, radius);
  34. }
  35. Timer::Stop("ConvTriangle_mlpack");
  36. }
  37. }
Add Comment
Please, Sign In to add comment