File: img_info.h

package info (click to toggle)
meshlab 1.3.0a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 23,416 kB
  • sloc: cpp: 214,034; ansic: 4,493; makefile: 72
file content (45 lines) | stat: -rwxr-xr-x 1,102 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef IMG_INFO_H_
#define IMG_INFO_H_

// functions that extrapolate information from read-only images

namespace img {

template<int Channels,typename ScalarType, bool Safe>
inline ScalarType minValue(const Image<Channels,ScalarType,Safe> &image)
{
  assert(image.isValid());
  if(Safe){
    if(!image.isValid())  throw ImageException("Invalid image");
  }
  ScalarType* array = image.dataValues();
  int length =image.dataValuesSize();

  ScalarType min = array[0];
  for(int offset=0;offset<length;offset++)
    if(min > array[offset])
      min = array[offset];
  return min;
}
  
template<int Channels,typename ScalarType, bool Safe>
inline ScalarType maxValue(const Image<Channels,ScalarType,Safe> &image)
{
  assert(image.isValid());
  if(Safe){
    if(!image.isValid())  throw ImageException("Invalid image");
  }
  ScalarType* array = image.dataValues();
  int length =image.dataValuesSize();

  ScalarType max = array[0];
  for(int offset=0;offset<length;offset++)
    if(max < array[offset])
      max = array[offset];
      
  return max;
}

} //end namespace img

#endif /*IMG_INFO_H_*/