mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-22 15:06:47 +01:00
Rename feature_map to z_slice in MLPPTensor3.
This commit is contained in:
parent
f849155159
commit
c9fb686853
@ -3,7 +3,7 @@
|
||||
|
||||
#include "core/io/image.h"
|
||||
|
||||
void MLPPTensor3::add_feature_maps_image(const Ref<Image> &p_img, const int p_channels) {
|
||||
void MLPPTensor3::add_z_slices_image(const Ref<Image> &p_img, const int p_channels) {
|
||||
ERR_FAIL_COND(!p_img.is_valid());
|
||||
|
||||
Size2i img_size = Size2i(p_img->get_width(), p_img->get_height());
|
||||
@ -37,7 +37,7 @@ void MLPPTensor3::add_feature_maps_image(const Ref<Image> &p_img, const int p_ch
|
||||
resize(Size3i(img_size.x, img_size.y, channel_count));
|
||||
}
|
||||
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
ERR_FAIL_COND(img_size != fms);
|
||||
|
||||
@ -64,7 +64,7 @@ void MLPPTensor3::add_feature_maps_image(const Ref<Image> &p_img, const int p_ch
|
||||
img->unlock();
|
||||
}
|
||||
|
||||
Ref<Image> MLPPTensor3::get_feature_map_image(const int p_index_z) const {
|
||||
Ref<Image> MLPPTensor3::get_z_slice_image(const int p_index_z) const {
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Ref<Image>());
|
||||
|
||||
Ref<Image> image;
|
||||
@ -76,8 +76,8 @@ Ref<Image> MLPPTensor3::get_feature_map_image(const int p_index_z) const {
|
||||
|
||||
PoolByteArray arr;
|
||||
|
||||
int fmsi = calculate_feature_map_index(p_index_z);
|
||||
int fms = feature_map_data_size();
|
||||
int fmsi = calculate_z_slice_index(p_index_z);
|
||||
int fms = z_slice_data_size();
|
||||
|
||||
arr.resize(fms);
|
||||
|
||||
@ -92,7 +92,7 @@ Ref<Image> MLPPTensor3::get_feature_map_image(const int p_index_z) const {
|
||||
|
||||
return image;
|
||||
}
|
||||
Ref<Image> MLPPTensor3::get_feature_maps_image(const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) const {
|
||||
Ref<Image> MLPPTensor3::get_z_slices_image(const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) const {
|
||||
if (p_index_r != -1) {
|
||||
ERR_FAIL_INDEX_V(p_index_r, _size.z, Ref<Image>());
|
||||
}
|
||||
@ -116,7 +116,7 @@ Ref<Image> MLPPTensor3::get_feature_maps_image(const int p_index_r, const int p_
|
||||
return image;
|
||||
}
|
||||
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
image->create(_size.x, _size.y, false, Image::FORMAT_RGBA8);
|
||||
|
||||
@ -151,7 +151,7 @@ Ref<Image> MLPPTensor3::get_feature_maps_image(const int p_index_r, const int p_
|
||||
return image;
|
||||
}
|
||||
|
||||
void MLPPTensor3::get_feature_map_into_image(Ref<Image> p_target, const int p_index_z, const int p_target_channels) const {
|
||||
void MLPPTensor3::get_z_slice_into_image(Ref<Image> p_target, const int p_index_z, const int p_target_channels) const {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
ERR_FAIL_COND(!p_target.is_valid());
|
||||
|
||||
@ -186,7 +186,7 @@ void MLPPTensor3::get_feature_map_into_image(Ref<Image> p_target, const int p_in
|
||||
}
|
||||
|
||||
Size2i img_size = Size2i(p_target->get_width(), p_target->get_height());
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
if (img_size != fms) {
|
||||
bool mip_maps = p_target->has_mipmaps();
|
||||
p_target->resize(fms.x, fms.y, Image::INTERPOLATE_NEAREST);
|
||||
@ -218,7 +218,7 @@ void MLPPTensor3::get_feature_map_into_image(Ref<Image> p_target, const int p_in
|
||||
|
||||
p_target->unlock();
|
||||
}
|
||||
void MLPPTensor3::get_feature_maps_into_image(Ref<Image> p_target, const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) const {
|
||||
void MLPPTensor3::get_z_slices_into_image(Ref<Image> p_target, const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) const {
|
||||
ERR_FAIL_COND(!p_target.is_valid());
|
||||
|
||||
if (p_index_r != -1) {
|
||||
@ -243,7 +243,7 @@ void MLPPTensor3::get_feature_maps_into_image(Ref<Image> p_target, const int p_i
|
||||
}
|
||||
|
||||
Size2i img_size = Size2i(p_target->get_width(), p_target->get_height());
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
if (img_size != fms) {
|
||||
bool mip_maps = p_target->has_mipmaps();
|
||||
p_target->resize(fms.x, fms.y, Image::INTERPOLATE_NEAREST);
|
||||
@ -286,7 +286,7 @@ void MLPPTensor3::get_feature_maps_into_image(Ref<Image> p_target, const int p_i
|
||||
p_target->unlock();
|
||||
}
|
||||
|
||||
void MLPPTensor3::set_feature_map_image(const Ref<Image> &p_img, const int p_index_z, const int p_image_channel_flag) {
|
||||
void MLPPTensor3::set_z_slice_image(const Ref<Image> &p_img, const int p_index_z, const int p_image_channel_flag) {
|
||||
ERR_FAIL_COND(!p_img.is_valid());
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
|
||||
@ -302,7 +302,7 @@ void MLPPTensor3::set_feature_map_image(const Ref<Image> &p_img, const int p_ind
|
||||
ERR_FAIL_INDEX(channel_index, 4);
|
||||
|
||||
Size2i img_size = Size2i(p_img->get_width(), p_img->get_height());
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
ERR_FAIL_COND(img_size != fms);
|
||||
|
||||
@ -320,7 +320,7 @@ void MLPPTensor3::set_feature_map_image(const Ref<Image> &p_img, const int p_ind
|
||||
|
||||
img->unlock();
|
||||
}
|
||||
void MLPPTensor3::set_feature_maps_image(const Ref<Image> &p_img, const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) {
|
||||
void MLPPTensor3::set_z_slices_image(const Ref<Image> &p_img, const int p_index_r, const int p_index_g, const int p_index_b, const int p_index_a) {
|
||||
ERR_FAIL_COND(!p_img.is_valid());
|
||||
|
||||
if (p_index_r != -1) {
|
||||
@ -340,7 +340,7 @@ void MLPPTensor3::set_feature_maps_image(const Ref<Image> &p_img, const int p_in
|
||||
}
|
||||
|
||||
Size2i img_size = Size2i(p_img->get_width(), p_img->get_height());
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
ERR_FAIL_COND(img_size != fms);
|
||||
|
||||
@ -405,7 +405,7 @@ void MLPPTensor3::set_from_image(const Ref<Image> &p_img, const int p_channels)
|
||||
|
||||
resize(Size3i(img_size.x, img_size.y, channel_count));
|
||||
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
Ref<Image> img = p_img;
|
||||
|
||||
@ -1072,21 +1072,21 @@ MLPPTensor3::MLPPTensor3(const std::vector<std::vector<std::vector<real_t>>> &p_
|
||||
}
|
||||
|
||||
void MLPPTensor3::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_feature_map_pool_vector", "row"), &MLPPTensor3::add_feature_map_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("add_feature_map_mlpp_vector", "row"), &MLPPTensor3::add_feature_map_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("add_feature_map_mlpp_matrix", "matrix"), &MLPPTensor3::add_feature_map_mlpp_matrix);
|
||||
ClassDB::bind_method(D_METHOD("add_z_slice_pool_vector", "row"), &MLPPTensor3::add_z_slice_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("add_z_slice_mlpp_vector", "row"), &MLPPTensor3::add_z_slice_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("add_z_slice_mlpp_matrix", "matrix"), &MLPPTensor3::add_z_slice_mlpp_matrix);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("remove_feature_map", "index"), &MLPPTensor3::remove_feature_map);
|
||||
ClassDB::bind_method(D_METHOD("remove_feature_map_unordered", "index"), &MLPPTensor3::remove_feature_map_unordered);
|
||||
ClassDB::bind_method(D_METHOD("remove_z_slice", "index"), &MLPPTensor3::remove_z_slice);
|
||||
ClassDB::bind_method(D_METHOD("remove_z_slice_unordered", "index"), &MLPPTensor3::remove_z_slice_unordered);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("swap_feature_map", "index_1", "index_2"), &MLPPTensor3::swap_feature_map);
|
||||
ClassDB::bind_method(D_METHOD("swap_z_slice", "index_1", "index_2"), &MLPPTensor3::swap_z_slice);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("clear"), &MLPPTensor3::clear);
|
||||
ClassDB::bind_method(D_METHOD("reset"), &MLPPTensor3::reset);
|
||||
ClassDB::bind_method(D_METHOD("empty"), &MLPPTensor3::empty);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("feature_map_data_size"), &MLPPTensor3::feature_map_data_size);
|
||||
ClassDB::bind_method(D_METHOD("feature_map_size"), &MLPPTensor3::feature_map_size);
|
||||
ClassDB::bind_method(D_METHOD("z_slice_data_size"), &MLPPTensor3::z_slice_data_size);
|
||||
ClassDB::bind_method(D_METHOD("z_slice_size"), &MLPPTensor3::z_slice_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("data_size"), &MLPPTensor3::data_size);
|
||||
ClassDB::bind_method(D_METHOD("size"), &MLPPTensor3::size);
|
||||
@ -1095,7 +1095,7 @@ void MLPPTensor3::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_shape", "size"), &MLPPTensor3::set_shape);
|
||||
ClassDB::bind_method(D_METHOD("calculate_index", "index_y", "index_x", "index_z"), &MLPPTensor3::calculate_index);
|
||||
ClassDB::bind_method(D_METHOD("calculate_feature_map_index", "index_z"), &MLPPTensor3::calculate_feature_map_index);
|
||||
ClassDB::bind_method(D_METHOD("calculate_z_slice_index", "index_z"), &MLPPTensor3::calculate_z_slice_index);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_element_index", "index"), &MLPPTensor3::get_element_index);
|
||||
ClassDB::bind_method(D_METHOD("set_element_index", "index", "val"), &MLPPTensor3::set_element_index);
|
||||
@ -1110,27 +1110,27 @@ void MLPPTensor3::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_row_pool_vector", "index_y", "index_z", "row"), &MLPPTensor3::set_row_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("set_row_mlpp_vector", "index_y", "index_z", "row"), &MLPPTensor3::set_row_mlpp_vector);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_pool_vector", "index_z"), &MLPPTensor3::get_feature_map_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_mlpp_vector", "index_z"), &MLPPTensor3::get_feature_map_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_into_mlpp_vector", "index_z", "target"), &MLPPTensor3::get_feature_map_into_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_pool_vector", "index_z"), &MLPPTensor3::get_z_slice_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_mlpp_vector", "index_z"), &MLPPTensor3::get_z_slice_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_into_mlpp_vector", "index_z", "target"), &MLPPTensor3::get_z_slice_into_mlpp_vector);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_mlpp_matrix", "index_z"), &MLPPTensor3::get_feature_map_mlpp_matrix);
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_into_mlpp_matrix", "index_z", "target"), &MLPPTensor3::get_feature_map_into_mlpp_matrix);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_mlpp_matrix", "index_z"), &MLPPTensor3::get_z_slice_mlpp_matrix);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_into_mlpp_matrix", "index_z", "target"), &MLPPTensor3::get_z_slice_into_mlpp_matrix);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_feature_map_pool_vector", "index_z", "row"), &MLPPTensor3::set_feature_map_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("set_feature_map_mlpp_vector", "index_z", "row"), &MLPPTensor3::set_feature_map_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("set_feature_map_mlpp_matrix", "index_z", "mat"), &MLPPTensor3::set_feature_map_mlpp_matrix);
|
||||
ClassDB::bind_method(D_METHOD("set_z_slice_pool_vector", "index_z", "row"), &MLPPTensor3::set_z_slice_pool_vector);
|
||||
ClassDB::bind_method(D_METHOD("set_z_slice_mlpp_vector", "index_z", "row"), &MLPPTensor3::set_z_slice_mlpp_vector);
|
||||
ClassDB::bind_method(D_METHOD("set_z_slice_mlpp_matrix", "index_z", "mat"), &MLPPTensor3::set_z_slice_mlpp_matrix);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_feature_maps_image", "img", "channels"), &MLPPTensor3::add_feature_maps_image, IMAGE_CHANNEL_FLAG_RGBA);
|
||||
ClassDB::bind_method(D_METHOD("add_z_slices_image", "img", "channels"), &MLPPTensor3::add_z_slices_image, IMAGE_CHANNEL_FLAG_RGBA);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_image", "index_z"), &MLPPTensor3::get_feature_map_image);
|
||||
ClassDB::bind_method(D_METHOD("get_feature_maps_image", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::get_feature_maps_image, -1, -1, -1, -1);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_image", "index_z"), &MLPPTensor3::get_z_slice_image);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slices_image", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::get_z_slices_image, -1, -1, -1, -1);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_feature_map_into_image", "target", "index_z", "target_channels"), &MLPPTensor3::get_feature_map_into_image, IMAGE_CHANNEL_FLAG_RGB);
|
||||
ClassDB::bind_method(D_METHOD("get_feature_maps_into_image", "target", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::get_feature_maps_into_image, -1, -1, -1, -1);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slice_into_image", "target", "index_z", "target_channels"), &MLPPTensor3::get_z_slice_into_image, IMAGE_CHANNEL_FLAG_RGB);
|
||||
ClassDB::bind_method(D_METHOD("get_z_slices_into_image", "target", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::get_z_slices_into_image, -1, -1, -1, -1);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_feature_map_image", "img", "index_z", "image_channel_flag"), &MLPPTensor3::set_feature_map_image, IMAGE_CHANNEL_FLAG_R);
|
||||
ClassDB::bind_method(D_METHOD("set_feature_maps_image", "img", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::set_feature_maps_image);
|
||||
ClassDB::bind_method(D_METHOD("set_z_slice_image", "img", "index_z", "image_channel_flag"), &MLPPTensor3::set_z_slice_image, IMAGE_CHANNEL_FLAG_R);
|
||||
ClassDB::bind_method(D_METHOD("set_z_slices_image", "img", "index_r", "index_g", "index_b", "index_a"), &MLPPTensor3::set_z_slices_image);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_from_image", "img", "channels"), &MLPPTensor3::set_from_image, IMAGE_CHANNEL_FLAG_RGBA);
|
||||
|
||||
|
@ -35,12 +35,12 @@ public:
|
||||
// TODO: Add Image get, set helper methods to MLPPMatrix -> so the other axis helper methods can use them.
|
||||
// TODO: _FORCE_INLINE_ less big methods (Also do this in MLPPVEctor and MLPPMatrix)
|
||||
|
||||
_FORCE_INLINE_ void add_feature_map(const Vector<real_t> &p_row) {
|
||||
_FORCE_INLINE_ void add_z_slice(const Vector<real_t> &p_row) {
|
||||
if (p_row.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int fms = feature_map_data_size();
|
||||
int fms = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(fms != p_row.size());
|
||||
|
||||
@ -58,12 +58,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void add_feature_map_pool_vector(const PoolRealArray &p_row) {
|
||||
_FORCE_INLINE_ void add_z_slice_pool_vector(const PoolRealArray &p_row) {
|
||||
if (p_row.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int fms = feature_map_data_size();
|
||||
int fms = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(fms != p_row.size());
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void add_feature_map_mlpp_vector(const Ref<MLPPVector> &p_row) {
|
||||
_FORCE_INLINE_ void add_z_slice_mlpp_vector(const Ref<MLPPVector> &p_row) {
|
||||
ERR_FAIL_COND(!p_row.is_valid());
|
||||
|
||||
int p_row_size = p_row->size();
|
||||
@ -91,7 +91,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int fms = feature_map_data_size();
|
||||
int fms = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(fms != p_row_size);
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void add_feature_map_mlpp_matrix(const Ref<MLPPMatrix> &p_matrix) {
|
||||
_FORCE_INLINE_ void add_z_slice_mlpp_matrix(const Ref<MLPPMatrix> &p_matrix) {
|
||||
ERR_FAIL_COND(!p_matrix.is_valid());
|
||||
|
||||
int other_data_size = p_matrix->data_size();
|
||||
@ -119,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
Size2i matrix_size = p_matrix->size();
|
||||
Size2i fms = feature_map_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
ERR_FAIL_COND(fms != matrix_size);
|
||||
|
||||
@ -137,7 +137,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void remove_feature_map(int p_index) {
|
||||
void remove_z_slice(int p_index) {
|
||||
ERR_FAIL_INDEX(p_index, _size.z);
|
||||
|
||||
--_size.z;
|
||||
@ -150,9 +150,9 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
for (int i = calculate_feature_map_index(p_index); i < ds; ++i) {
|
||||
for (int i = calculate_z_slice_index(p_index); i < ds; ++i) {
|
||||
_data[i] = _data[i + fmds];
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public:
|
||||
|
||||
// Removes the item copying the last value into the position of the one to
|
||||
// remove. It's generally faster than `remove`.
|
||||
void remove_feature_map_unordered(int p_index) {
|
||||
void remove_z_slice_unordered(int p_index) {
|
||||
ERR_FAIL_INDEX(p_index, _size.z);
|
||||
|
||||
--_size.z;
|
||||
@ -175,8 +175,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int start_ind = calculate_feature_map_index(p_index);
|
||||
int end_ind = calculate_feature_map_index(p_index + 1);
|
||||
int start_ind = calculate_z_slice_index(p_index);
|
||||
int end_ind = calculate_z_slice_index(p_index + 1);
|
||||
|
||||
for (int i = start_ind; i < end_ind; ++i) {
|
||||
_data[i] = _data[ds + i];
|
||||
@ -186,14 +186,14 @@ public:
|
||||
CRASH_COND_MSG(!_data, "Out of memory");
|
||||
}
|
||||
|
||||
void swap_feature_map(int p_index_1, int p_index_2) {
|
||||
void swap_z_slice(int p_index_1, int p_index_2) {
|
||||
ERR_FAIL_INDEX(p_index_1, _size.z);
|
||||
ERR_FAIL_INDEX(p_index_2, _size.z);
|
||||
|
||||
int ind1_start = calculate_feature_map_index(p_index_1);
|
||||
int ind2_start = calculate_feature_map_index(p_index_2);
|
||||
int ind1_start = calculate_z_slice_index(p_index_1);
|
||||
int ind2_start = calculate_z_slice_index(p_index_2);
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
for (int i = 0; i < fmds; ++i) {
|
||||
SWAP(_data[ind1_start + i], _data[ind2_start + i]);
|
||||
@ -210,8 +210,8 @@ public:
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool empty() const { return _size == Size3i(); }
|
||||
_FORCE_INLINE_ int feature_map_data_size() const { return _size.x * _size.y; }
|
||||
_FORCE_INLINE_ Size2i feature_map_size() const { return Size2i(_size.x, _size.y); }
|
||||
_FORCE_INLINE_ int z_slice_data_size() const { return _size.x * _size.y; }
|
||||
_FORCE_INLINE_ Size2i z_slice_size() const { return Size2i(_size.x, _size.y); }
|
||||
_FORCE_INLINE_ int data_size() const { return _size.x * _size.y * _size.z; }
|
||||
_FORCE_INLINE_ Size3i size() const { return _size; }
|
||||
|
||||
@ -246,7 +246,7 @@ public:
|
||||
return p_index_y * _size.x + p_index_x + _size.x * _size.y * p_index_z;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int calculate_feature_map_index(int p_index_z) const {
|
||||
_FORCE_INLINE_ int calculate_z_slice_index(int p_index_z) const {
|
||||
return _size.x * _size.y * p_index_z;
|
||||
}
|
||||
|
||||
@ -420,12 +420,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector<real_t> get_feature_map_vector(int p_index_z) const {
|
||||
_FORCE_INLINE_ Vector<real_t> get_z_slice_vector(int p_index_z) const {
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Vector<real_t>());
|
||||
|
||||
Vector<real_t> ret;
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
if (unlikely(fmds == 0)) {
|
||||
return ret;
|
||||
@ -433,7 +433,7 @@ public:
|
||||
|
||||
ret.resize(fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
real_t *row_ptr = ret.ptrw();
|
||||
|
||||
@ -444,12 +444,12 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ PoolRealArray get_feature_map_pool_vector(int p_index_z) const {
|
||||
_FORCE_INLINE_ PoolRealArray get_z_slice_pool_vector(int p_index_z) const {
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, PoolRealArray());
|
||||
|
||||
PoolRealArray ret;
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
if (unlikely(fmds == 0)) {
|
||||
return ret;
|
||||
@ -457,7 +457,7 @@ public:
|
||||
|
||||
ret.resize(fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
PoolRealArray::Write w = ret.write();
|
||||
real_t *row_ptr = w.ptr();
|
||||
@ -469,13 +469,13 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Ref<MLPPVector> get_feature_map_mlpp_vector(int p_index_z) const {
|
||||
_FORCE_INLINE_ Ref<MLPPVector> get_z_slice_mlpp_vector(int p_index_z) const {
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Ref<MLPPVector>());
|
||||
|
||||
Ref<MLPPVector> ret;
|
||||
ret.instance();
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
if (unlikely(fmds == 0)) {
|
||||
return ret;
|
||||
@ -483,7 +483,7 @@ public:
|
||||
|
||||
ret->resize(fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
real_t *row_ptr = ret->ptrw();
|
||||
|
||||
@ -494,16 +494,16 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void get_feature_map_into_mlpp_vector(int p_index_z, Ref<MLPPVector> target) const {
|
||||
_FORCE_INLINE_ void get_z_slice_into_mlpp_vector(int p_index_z, Ref<MLPPVector> target) const {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
if (unlikely(target->size() != fmds)) {
|
||||
target->resize(fmds);
|
||||
}
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
real_t *row_ptr = target->ptrw();
|
||||
|
||||
@ -512,21 +512,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Ref<MLPPMatrix> get_feature_map_mlpp_matrix(int p_index_z) const {
|
||||
_FORCE_INLINE_ Ref<MLPPMatrix> get_z_slice_mlpp_matrix(int p_index_z) const {
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Ref<MLPPMatrix>());
|
||||
|
||||
Ref<MLPPMatrix> ret;
|
||||
ret.instance();
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
if (unlikely(fmds == 0)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret->resize(feature_map_size());
|
||||
ret->resize(z_slice_size());
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
real_t *row_ptr = ret->ptrw();
|
||||
|
||||
@ -537,17 +537,17 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void get_feature_map_into_mlpp_matrix(int p_index_z, Ref<MLPPMatrix> target) const {
|
||||
_FORCE_INLINE_ void get_z_slice_into_mlpp_matrix(int p_index_z, Ref<MLPPMatrix> target) const {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
Size2i fms = feature_map_size();
|
||||
int fmds = z_slice_data_size();
|
||||
Size2i fms = z_slice_size();
|
||||
|
||||
if (unlikely(target->size() != fms)) {
|
||||
target->resize(fms);
|
||||
}
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
real_t *row_ptr = target->ptrw();
|
||||
|
||||
@ -556,14 +556,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_feature_map_vector(int p_index_z, const Vector<real_t> &p_row) {
|
||||
_FORCE_INLINE_ void set_z_slice_vector(int p_index_z, const Vector<real_t> &p_row) {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(p_row.size() != fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
const real_t *row_ptr = p_row.ptr();
|
||||
|
||||
@ -572,14 +572,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_feature_map_pool_vector(int p_index_z, const PoolRealArray &p_row) {
|
||||
_FORCE_INLINE_ void set_z_slice_pool_vector(int p_index_z, const PoolRealArray &p_row) {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(p_row.size() != fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
PoolRealArray::Read r = p_row.read();
|
||||
const real_t *row_ptr = r.ptr();
|
||||
@ -589,15 +589,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_feature_map_mlpp_vector(int p_index_z, const Ref<MLPPVector> &p_row) {
|
||||
_FORCE_INLINE_ void set_z_slice_mlpp_vector(int p_index_z, const Ref<MLPPVector> &p_row) {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
ERR_FAIL_COND(!p_row.is_valid());
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(p_row->size() != fmds);
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
const real_t *row_ptr = p_row->ptr();
|
||||
|
||||
@ -606,15 +606,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_feature_map_mlpp_matrix(int p_index_z, const Ref<MLPPMatrix> &p_mat) {
|
||||
_FORCE_INLINE_ void set_z_slice_mlpp_matrix(int p_index_z, const Ref<MLPPMatrix> &p_mat) {
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
ERR_FAIL_COND(!p_mat.is_valid());
|
||||
|
||||
int fmds = feature_map_data_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
ERR_FAIL_COND(p_mat->size() != feature_map_size());
|
||||
ERR_FAIL_COND(p_mat->size() != z_slice_size());
|
||||
|
||||
int ind_start = calculate_feature_map_index(p_index_z);
|
||||
int ind_start = calculate_z_slice_index(p_index_z);
|
||||
|
||||
const real_t *row_ptr = p_mat->ptr();
|
||||
|
||||
@ -641,16 +641,16 @@ public:
|
||||
IMAGE_CHANNEL_FLAG_RGBA = IMAGE_CHANNEL_FLAG_R | IMAGE_CHANNEL_FLAG_G | IMAGE_CHANNEL_FLAG_B | IMAGE_CHANNEL_FLAG_A,
|
||||
};
|
||||
|
||||
void add_feature_maps_image(const Ref<Image> &p_img, const int p_channels = IMAGE_CHANNEL_FLAG_RGBA);
|
||||
void add_z_slices_image(const Ref<Image> &p_img, const int p_channels = IMAGE_CHANNEL_FLAG_RGBA);
|
||||
|
||||
Ref<Image> get_feature_map_image(const int p_index_z) const;
|
||||
Ref<Image> get_feature_maps_image(const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1) const;
|
||||
Ref<Image> get_z_slice_image(const int p_index_z) const;
|
||||
Ref<Image> get_z_slices_image(const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1) const;
|
||||
|
||||
void get_feature_map_into_image(Ref<Image> p_target, const int p_index_z, const int p_target_channels = IMAGE_CHANNEL_FLAG_RGB) const;
|
||||
void get_feature_maps_into_image(Ref<Image> p_target, const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1) const;
|
||||
void get_z_slice_into_image(Ref<Image> p_target, const int p_index_z, const int p_target_channels = IMAGE_CHANNEL_FLAG_RGB) const;
|
||||
void get_z_slices_into_image(Ref<Image> p_target, const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1) const;
|
||||
|
||||
void set_feature_map_image(const Ref<Image> &p_img, const int p_index_z, const int p_image_channel_flag = IMAGE_CHANNEL_FLAG_R);
|
||||
void set_feature_maps_image(const Ref<Image> &p_img, const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1);
|
||||
void set_z_slice_image(const Ref<Image> &p_img, const int p_index_z, const int p_image_channel_flag = IMAGE_CHANNEL_FLAG_R);
|
||||
void set_z_slices_image(const Ref<Image> &p_img, const int p_index_r = -1, const int p_index_g = -1, const int p_index_b = -1, const int p_index_a = -1);
|
||||
|
||||
void set_from_image(const Ref<Image> &p_img, const int p_channels = IMAGE_CHANNEL_FLAG_RGBA);
|
||||
|
||||
@ -857,8 +857,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Size2i fms = feature_map_size();
|
||||
int fmds = feature_map_data_size();
|
||||
Size2i fms = z_slice_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
for (int i = 0; i < p_from.size(); ++i) {
|
||||
const Ref<MLPPMatrix> &r = p_from[i];
|
||||
@ -866,7 +866,7 @@ public:
|
||||
ERR_CONTINUE(!r.is_valid());
|
||||
ERR_CONTINUE(r->size() != fms);
|
||||
|
||||
int start_index = calculate_feature_map_index(i);
|
||||
int start_index = calculate_z_slice_index(i);
|
||||
|
||||
const real_t *from_ptr = r->ptr();
|
||||
for (int j = 0; j < fmds; j++) {
|
||||
@ -930,8 +930,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Size2i fms = feature_map_size();
|
||||
int fmds = feature_map_data_size();
|
||||
Size2i fms = z_slice_size();
|
||||
int fmds = z_slice_data_size();
|
||||
|
||||
for (int i = 0; i < p_from.size(); ++i) {
|
||||
Ref<MLPPMatrix> r = p_from[i];
|
||||
@ -939,7 +939,7 @@ public:
|
||||
ERR_CONTINUE(!r.is_valid());
|
||||
ERR_CONTINUE(r->size() != fms);
|
||||
|
||||
int start_index = calculate_feature_map_index(i);
|
||||
int start_index = calculate_z_slice_index(i);
|
||||
|
||||
const real_t *from_ptr = r->ptr();
|
||||
for (int j = 0; j < fmds; j++) {
|
||||
|
Loading…
Reference in New Issue
Block a user