2023-01-24 18:52:45 +01:00
|
|
|
|
|
|
|
#ifndef MLPP_CONVOLUTIONS_H
|
|
|
|
#define MLPP_CONVOLUTIONS_H
|
2023-01-23 21:13:26 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
#include "core/containers/vector.h"
|
|
|
|
#include "core/string/ustring.h"
|
2023-01-23 21:13:26 +01:00
|
|
|
|
2023-01-27 13:01:16 +01:00
|
|
|
#include "core/math/math_defs.h"
|
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
#include "../lin_alg/mlpp_matrix.h"
|
|
|
|
#include "../lin_alg/mlpp_tensor3.h"
|
|
|
|
#include "../lin_alg/mlpp_vector.h"
|
|
|
|
|
2023-02-12 18:20:53 +01:00
|
|
|
#include "core/object/reference.h"
|
|
|
|
|
|
|
|
class MLPPConvolutions : public Reference {
|
|
|
|
GDCLASS(MLPPConvolutions, Reference);
|
|
|
|
|
2023-01-24 19:00:54 +01:00
|
|
|
public:
|
2023-12-28 14:41:45 +01:00
|
|
|
enum PoolType {
|
|
|
|
POOL_TYPE_AVERAGE = 0,
|
|
|
|
POOL_TYPE_MIN,
|
|
|
|
POOL_TYPE_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
Ref<MLPPMatrix> convolve_2d(const Ref<MLPPMatrix> &input, const Ref<MLPPMatrix> &filter, const int S, const int P = 0);
|
|
|
|
Ref<MLPPTensor3> convolve_3d(const Ref<MLPPTensor3> &input, const Ref<MLPPTensor3> &filter, const int S, const int P = 0);
|
|
|
|
|
|
|
|
Ref<MLPPMatrix> pool_2d(const Ref<MLPPMatrix> &input, const int F, const int S, const PoolType type);
|
|
|
|
Ref<MLPPTensor3> pool_3d(const Ref<MLPPTensor3> &input, const int F, const int S, const PoolType type);
|
2023-02-13 00:45:07 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
real_t global_pool_2d(const Ref<MLPPMatrix> &input, const PoolType type);
|
|
|
|
Ref<MLPPVector> global_pool_3d(const Ref<MLPPTensor3> &input, const PoolType type);
|
2023-02-13 00:45:07 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
real_t gaussian_2d(const real_t x, const real_t y, const real_t std);
|
|
|
|
Ref<MLPPMatrix> gaussian_filter_2d(const int size, const real_t std);
|
2023-01-27 13:01:16 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
Ref<MLPPMatrix> dx(const Ref<MLPPMatrix> &input);
|
|
|
|
Ref<MLPPMatrix> dy(const Ref<MLPPMatrix> &input);
|
2023-01-27 13:01:16 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
Ref<MLPPMatrix> grad_magnitude(const Ref<MLPPMatrix> &input);
|
|
|
|
Ref<MLPPMatrix> grad_orientation(const Ref<MLPPMatrix> &input);
|
2023-01-27 13:01:16 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
Ref<MLPPTensor3> compute_m(const Ref<MLPPMatrix> &input);
|
|
|
|
Vector<Ref<MLPPMatrix>> compute_mv(const Ref<MLPPMatrix> &input);
|
2023-01-27 13:01:16 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
//TODO better data srtucture for this. Maybe IntMatrix?
|
|
|
|
Vector<Vector<CharType>> harris_corner_detection(const Ref<MLPPMatrix> &input);
|
2023-01-27 13:01:16 +01:00
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
Ref<MLPPMatrix> get_prewitt_horizontal() const;
|
|
|
|
Ref<MLPPMatrix> get_prewitt_vertical() const;
|
|
|
|
Ref<MLPPMatrix> get_sobel_horizontal() const;
|
|
|
|
Ref<MLPPMatrix> get_sobel_vertical() const;
|
|
|
|
Ref<MLPPMatrix> get_scharr_horizontal() const;
|
|
|
|
Ref<MLPPMatrix> get_scharr_vertical() const;
|
|
|
|
Ref<MLPPMatrix> get_roberts_horizontal() const;
|
|
|
|
Ref<MLPPMatrix> get_roberts_vertical() const;
|
2023-02-13 00:45:07 +01:00
|
|
|
|
|
|
|
MLPPConvolutions();
|
2023-01-24 19:00:54 +01:00
|
|
|
|
2023-02-12 18:20:53 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2023-12-28 14:41:45 +01:00
|
|
|
Ref<MLPPMatrix> _prewitt_horizontal;
|
|
|
|
Ref<MLPPMatrix> _prewitt_vertical;
|
|
|
|
Ref<MLPPMatrix> _sobel_horizontal;
|
|
|
|
Ref<MLPPMatrix> _sobel_vertical;
|
|
|
|
Ref<MLPPMatrix> _scharr_horizontal;
|
|
|
|
Ref<MLPPMatrix> _scharr_vertical;
|
|
|
|
Ref<MLPPMatrix> _roberts_horizontal;
|
|
|
|
Ref<MLPPMatrix> _roberts_vertical;
|
2023-01-24 19:00:54 +01:00
|
|
|
};
|
2023-01-23 21:13:26 +01:00
|
|
|
|
|
|
|
#endif // Convolutions_hpp
|