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