mae.cpp
Go to the documentation of this file.
1 #include "mae.h"
2 
4 {
5 
7  {
8  double sum = 0;
9  int width = p1->getShape().at(0);
10  int height = p1->getShape().at(1);
11  int colors = p1->getShape().at(2);
12 
13  auto first_image = p1->getDataAsVector();
14  auto second_image = p2->getDataAsVector();
15 
16  ARMARX_CHECK(first_image.size() == second_image.size());
17 
18  for (int w = 0; w < width; w++){
19  for (int h = 0; h < height; h++){
20  for (int c = 0; c < colors; c++){
21  int k = h * width * colors + w * colors + c;
22  sum += std::abs(first_image.at(k) - second_image.at(k));
23  }
24  }
25  }
26  return sum / (width * height * colors);
27  }
28 
29 
30 }
31 
armarx::aron::data::NDArrayPtr
std::shared_ptr< NDArray > NDArrayPtr
Definition: NDArray.h:46
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
armarx::aron::similarity::mae
Definition: mae.cpp:3
mae.h
armarx::aron::similarity::mae::compute_similarity
double compute_similarity(const data::NDArrayPtr p1, const data::NDArrayPtr p2)
Definition: mae.cpp:6