libpniio
image_info.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2011 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpniio.
5 //
6 // libpniio is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpniio is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpniio. If not, see <http://www.gnu.org/licenses/>.
18 // ===========================================================================
19 //
20 // Created on: Apr 23, 2012
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 //
24 #pragma once
25 
26 #include <iostream>
27 #include <vector>
28 #include <numeric>
29 
30 #include <pni/core/types.hpp>
31 #include <pni/core/error.hpp>
32 #include "image_channel_info.hpp"
33 
34 namespace pni{
35 namespace io{
36 
43  class image_info
44  {
45  private:
47  size_t _nx;
49  size_t _ny;
51  std::vector<image_channel_info> _channel_info;
52  public:
53  //-----------------------------------------------------------------
56  _nx(0),
57  _ny(0),
58  _channel_info(0)
59  {}
60 
61  //-----------------------------------------------------------------
68  image_info(size_t nx,size_t ny);
69 
70  //-----------------------------------------------------------------
73 
74  //-----------------------------------------------------------------
76  image_info(const image_info &i);
77 
78  //-----------------------------------------------------------------
81 
82  //-----------------------------------------------------------------
84  image_info &operator=(const image_info &i);
85 
86  //====================general class methods========================
92  size_t nx() const { return _nx; }
93 
94  //-----------------------------------------------------------------
100  size_t ny() const { return _ny; }
101 
102  //-----------------------------------------------------------------
109  size_t npixels() const { return _nx*_ny;}
110 
111  //-----------------------------------------------------------------
118  size_t bit_per_pixel() const
119  {
120  std::vector<size_t> bpc = bits_per_channel();
121  return std::accumulate(bpc.begin(),
122  bpc.end(),0);
123  }
124 
125  //-----------------------------------------------------------------
132  std::vector<size_t> bits_per_channel() const;
133 
134  //-----------------------------------------------------------------
141  std::vector<pni::core::type_id_t> types_per_channel() const;
142 
143  //-----------------------------------------------------------------
149  size_t nchannels() const { return _channel_info.size(); }
150 
151  //-----------------------------------------------------------------
159  void append_channel(const image_channel_info &i);
160 
161  //-----------------------------------------------------------------
169  image_channel_info get_channel(size_t i) const;
170 
171 
172 
173  };
174 
183  std::ostream &operator<<(std::ostream &o,const image_info &i);
184 
185 
186 
187 
188 //end of namespace
189 }
190 }
image information type
Definition: image_info.hpp:43
std::ostream & operator<<(std::ostream &o, const column_info &ci)
Definition: column_info.cpp:95
std::vector< image_channel_info > _channel_info
channel information
Definition: image_info.hpp:51
image_info & operator=(image_info &&i)
move assignment operator
Definition: image_info.cpp:61
image channel information class
Definition: image_channel_info.hpp:39
size_t ny() const
get pixels along y
Definition: image_info.hpp:100
size_t bit_per_pixel() const
get number of bits per pixel
Definition: image_info.hpp:118
void append_channel(const image_channel_info &i)
append a new channel
Definition: image_info.cpp:121
std::vector< size_t > bits_per_channel() const
get bits per channel
Definition: image_info.cpp:85
Definition: cbf_reader.hpp:41
size_t _nx
number of pixels in x-direction
Definition: image_info.hpp:47
size_t npixels() const
get total number of pixels
Definition: image_info.hpp:109
std::vector< pni::core::type_id_t > types_per_channel() const
get types per channel
Definition: image_info.cpp:103
image_channel_info get_channel(size_t i) const
get channel information
Definition: image_info.cpp:127
image_info()
default constructor
Definition: image_info.hpp:55
size_t nchannels() const
get number of channels
Definition: image_info.hpp:149
size_t nx() const
get pixels along x
Definition: image_info.hpp:92
size_t _ny
number of pixels in y-direction
Definition: image_info.hpp:49