CUV
0.9.201304091348
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
cuv
basics
image.hpp
Go to the documentation of this file.
1
//*LB*
2
// Copyright (c) 2010, University of Bonn, Institute for Computer Science VI
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
7
//
8
// * Redistributions of source code must retain the above copyright notice,
9
// this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright notice,
11
// this list of conditions and the following disclaimer in the documentation
12
// and/or other materials provided with the distribution.
13
// * Neither the name of the University of Bonn
14
// nor the names of its contributors may be used to endorse or promote
15
// products derived from this software without specific prior written
16
// permission.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
//*LE*
29
37
#ifndef __IMAGE_HPP__
38
#define __IMAGE_HPP__
39
#include <
cuv/basics/tensor.hpp
>
40
41
namespace
cuv
42
{
49
template
<
int
NumChannels,
class
__value_type,
class
__memory_space_type>
50
class
51
interleaved_image
{
52
public
:
54
typedef
cuv::tensor<__value_type,__memory_space_type,row_major>
tensor_type
;
56
typedef
typename
tensor_type::index_type
index_type
;
58
typedef
typename
tensor_type::reference_type
reference_type
;
59
private
:
60
tensor_type
m_tens;
61
unsigned
int
m_height;
62
unsigned
int
m_width;
63
public
:
64
static
const
int
num_channels = NumChannels;
72
interleaved_image
(
unsigned
int
h,
unsigned
int
w,
unsigned
int
c=1)
73
: m_tens(extents[h][w*NumChannels]),
74
m_height(h),
75
m_width(w)
76
{
77
}
82
interleaved_image
(
const
interleaved_image
& o)
83
: m_tens(o.
tens
()),
84
m_height(o.
height
()),
85
m_width(o.
width
())
86
{
87
}
88
90
inline
index_type
width
()
const
{
return
m_width; }
92
inline
index_type
height
()
const
{
return
m_height; }
94
inline
index_type
channels
()
const
{
return
NumChannels; }
95
97
inline
const
tensor_type
&
tens
()
const
{
return
m_tens; }
98
106
reference_type
107
operator()
(
index_type
i,
index_type
j,
index_type
c=0){
108
return
m_tens(i,j*NumChannels+c);
109
}
110
118
const
reference_type
119
operator()
(
index_type
i,
index_type
j,
index_type
c=0)
const
{
120
return
m_tens(i,j*NumChannels+c);
121
}
122
128
interleaved_image
&
129
operator=
(
const
interleaved_image
& o){
130
m_width = o.
width
();
131
m_height = o.
height
();
132
m_tens = o.
tens
();
133
return
*
this
;
134
}
135
};
136
}
137
138
139
#endif
/* __IMAGE_HPP__ */
Generated on Tue Apr 9 2013 13:48:56 for CUV by
1.8.1.2