9 : std::vector<float>(height_npixel*width_npixel,0.)
10 , _meta(0.,0.,width_npixel,height_npixel,0.,0.)
14 : std::vector<float>(meta.num_pixel_row()*meta.num_pixel_column(),0.)
19 : std::vector<float>(rhs)
25 std::vector<float>::resize(height_npixel*width_npixel);
30 std::vector<float>::clear();
44 {
for(
auto& v : (*
this)) v=value; }
47 {
return (*
this)[
index(h,w)]; }
56 void Image2D::copy(
size_t w,
size_t h,
const float* src,
size_t num_pixel)
58 const size_t idx =
index(h,w);
59 if(idx+num_pixel >= size())
throw larbys(
"memcpy size exceeds allocated memory!");
61 memcpy(&((*
this)[idx]),src, num_pixel *
sizeof(
float));
65 void Image2D::copy(
size_t w,
size_t h,
const std::vector<float>& src,
size_t num_pixel)
68 this->
copy(h,w,(
float*)(&(src[0])),src.size());
69 else if(num_pixel < src.size())
70 this->
copy(h,w,(
float*)&src[0],num_pixel);
72 throw larbys(
"Not enough pixel in source!");
75 void Image2D::copy(
size_t w,
size_t h,
const short* src,
size_t num_pixel)
77 const size_t idx =
index(h,w);
78 if(idx+num_pixel >= size())
throw larbys(
"memcpy size exceeds allocated memory!");
80 for(
size_t i=0; i<num_pixel; ++i) (*
this)[idx+i] = src[num_pixel];
84 void Image2D::copy(
size_t w,
size_t h,
const std::vector<short>& src,
size_t num_pixel)
87 this->
copy(h,w,(
short*)(&(src[0])),src.size());
88 else if(num_pixel < src.size())
89 this->
copy(h,w,(
short*)&src[0],num_pixel);
91 throw larbys(
"Not enough pixel in source!");
97 throw larbys(
"Compression only possible if height/width are modular 0 of compression factor!");
102 meta.
update(height,width);
105 for(
size_t w=0; w<
width; ++ w) {
106 for(
size_t h=0; h<
height; ++h) {
109 for(
size_t orig_w=w*width_factor; orig_w<(w+1)*width_factor; ++orig_w)
110 for(
size_t orig_h=h*height_factor; orig_h<(h+1)*height_factor; ++orig_h) {
115 result[w*height + h] = value;