image_metric.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <cstring>
17 #include "interop/util/exception.h"
22 
23 namespace illumina { namespace interop { namespace model { namespace metrics
24 {
28  {
29  public:
30  enum
31  {
34  };
37  typedef ::uint16_t ushort_t;
38  public:
43  image_metric_header(ushort_t channel_count) : m_channel_count(channel_count)
44  { }
45 
51  ushort_t channelCount() const
52  { return m_channel_count; }
57  ushort_t channel_count() const
58  { return m_channel_count; }
63  void channel_count(const size_t channel_count)
64  {
65  m_channel_count = static_cast<ushort_t>(channel_count);
66  }
67 
73  {
75  }
78  void clear()
79  {
80  m_channel_count=MAX_CHANNELS;
82  }
83 
84  private:
85  ushort_t m_channel_count;
86  template<class MetricType, int Version>
87  friend
88  struct io::generic_layout;
89  };
90 
98  {
99  public:
100  enum
101  {
108  };
114  typedef std::vector<ushort_t> ushort_array_t;
117  typedef ::uint16_t *ushort_pointer_t;
118  public:
122  metric_base::base_cycle_metric(0, 0, 0),
123  m_min_contrast(MAX_CHANNELS, std::numeric_limits<ushort_t>::max()),
124  m_max_contrast(MAX_CHANNELS, std::numeric_limits<ushort_t>::max()),
125  m_channel_count(0)
126  { }
131  image_metric(const header_type& header) :
132  metric_base::base_cycle_metric(0, 0, 0),
133  m_min_contrast(header.channel_count(), std::numeric_limits<ushort_t>::max()),
134  m_max_contrast(header.channel_count(), std::numeric_limits<ushort_t>::max()),
135  m_channel_count(0)
136  { }
137 
149  const uint_t tile,
150  const uint_t cycle,
151  const ushort_t channel_count,
152  const ushort_array_t &min_contrast,
153  const ushort_array_t &max_contrast) :
154  metric_base::base_cycle_metric(lane, tile, cycle),
155  m_min_contrast(min_contrast),
156  m_max_contrast(max_contrast),
157  m_channel_count(channel_count)
158  {
159  }
160 
172  const uint_t tile,
173  const uint_t cycle,
174  const ushort_t channel_count,
175  const ushort_pointer_t min_contrast,
176  const ushort_pointer_t max_contrast) :
177  metric_base::base_cycle_metric(lane, tile, cycle),
178  m_min_contrast(min_contrast, min_contrast + channel_count),
179  m_max_contrast(max_contrast, max_contrast + channel_count),
180  m_channel_count(channel_count)
181  {
182  }
183 
184  public:
200  {
201  INTEROP_BOUNDS_CHECK(channel, m_min_contrast.size(), "Channel out of bounds");
202  return m_min_contrast[channel];
203  }
204 
210  {
211  INTEROP_BOUNDS_CHECK(channel, m_max_contrast.size(), "Channel out of bounds");
212  return m_max_contrast[channel];
213  }
214 
219  const ushort_array_t &min_contrast_array() const
220  {
221  return m_min_contrast;
222  }
223 
228  const ushort_array_t &max_contrast_array() const
229  {
230  return m_max_contrast;
231  }
232 
238  {
239  return m_channel_count;
240  }
241 
246  bool is_any_channel_blank() const
247  {
248  for(size_t channel = 0; channel < channel_count(); ++channel)
249  {
250  if(max_contrast(channel) == 0 && min_contrast(channel) == 0)
251  return true;
252  }
253  return false;
254  }
255 
261  void trim(const size_t channel_count)
262  {
263  m_channel_count = static_cast<ushort_t>(channel_count);
264  m_max_contrast.resize(channel_count);
265  m_min_contrast.resize(channel_count);
266  }
272  ushort_t minContrast(size_t channel) const
273  {
274  INTEROP_ASSERT(channel < m_channel_count);
275  return m_min_contrast[channel];
276  }
277 
283  ushort_t maxContrast(size_t channel) const
284  {
285  INTEROP_ASSERT(channel < m_channel_count);
286  return m_max_contrast[channel];
287  }
288 
294  const ushort_array_t &minContrast() const
295  {
296  return m_min_contrast;
297  }
298 
304  const ushort_array_t &maxContrast() const
305  {
306  return m_max_contrast;
307  }
308 
315  {
316  return m_channel_count;
317  }
318 
319  public:
324  static const char *prefix()
325  { return "Image"; }
326 
327  private:
328  ushort_array_t m_min_contrast;
329  ushort_array_t m_max_contrast;
330  ushort_t m_channel_count;
331  template<class MetricType, int Version>
332  friend
333  struct io::generic_layout;
334  };
335 }}}}
336 
337 
static const char * prefix()
Definition: image_metric.h:324
ushort_t channelCount() const
Definition: image_metric.h:51
image_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ushort_t channel_count, const ushort_array_t &min_contrast, const ushort_array_t &max_contrast)
Definition: image_metric.h:148
image_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ushort_t channel_count, const ushort_pointer_t min_contrast, const ushort_pointer_t max_contrast)
Definition: image_metric.h:171
Definition: enum_description.h:15
uint_t tile() const
Definition: base_metric.h:284
ushort_t maxContrast(size_t channel) const
Definition: image_metric.h:283
const ushort_array_t & minContrast() const
Definition: image_metric.h:294
ushort_t max_contrast(const size_t channel) const INTEROP_THROW_SPEC((model
Definition: image_metric.h:209
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
std::vector< ushort_t > ushort_array_t
Definition: image_metric.h:114
const ushort_array_t & min_contrast_array() const
Definition: image_metric.h:219
ushort_t channelCount() const
Definition: image_metric.h:314
void clear()
Definition: image_metric.h:78
::uint16_t * ushort_pointer_t
Definition: image_metric.h:117
::uint16_t ushort_t
Definition: base_metric.h:141
image_metric_header header_type
Definition: image_metric.h:111
base_cycle_metric(const uint_t lane=0, const uint_t tile=0, const uint_t cycle=0)
Definition: base_cycle_metric.h:90
uint_t cycle() const
Definition: base_cycle_metric.h:131
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
void trim(const size_t channel_count)
Definition: image_metric.h:261
::uint32_t uint_t
Definition: base_metric.h:77
Definition: generic_layout.h:24
image_metric()
Definition: image_metric.h:121
uint_t lane() const
Definition: base_metric.h:269
static image_metric_header default_header()
Definition: image_metric.h:72
const ushort_array_t & maxContrast() const
Definition: image_metric.h:304
::uint16_t ushort_t
Definition: image_metric.h:37
void channel_count(const size_t channel_count)
Definition: image_metric.h:63
ushort_t min_contrast(const size_t channel) const INTEROP_THROW_SPEC((model
Definition: image_metric.h:199
bool is_any_channel_blank() const
Definition: image_metric.h:246
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
ushort_t channel_count() const
Definition: image_metric.h:57
image_metric_header(ushort_t channel_count)
Definition: image_metric.h:43
const ushort_array_t & max_contrast_array() const
Definition: image_metric.h:228
ushort_t channel_count() const
Definition: image_metric.h:237
image_metric(const header_type &header)
Definition: image_metric.h:131
ushort_t minContrast(size_t channel) const
Definition: image_metric.h:272