LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
afw
11.0-2-g04d2804
include
lsst
afw
gpu
detail
GpuBuffer2D.h
Go to the documentation of this file.
1
// -*- LSST-C++ -*-
2
3
/*
4
* LSST Data Management System
5
* Copyright 2008 - 2012 LSST Corporation.
6
*
7
* This product includes software developed by the
8
* LSST Project (http://www.lsst.org/).
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the LSST License Statement and
21
* the GNU General Public License along with this program. If not,
22
* see <http://www.lsstcorp.org/LegalNotices/>.
23
*/
24
35
namespace
lsst {
36
namespace
afw {
37
namespace
gpu {
38
namespace
detail {
39
53
template
<
typename
PixelT>
54
class
GpuBuffer2D
55
{
56
public
:
57
typedef
lsst::afw::image::Image<PixelT>
ImageT
;
58
59
PixelT
*
img
;
60
int
width
;
61
int
height
;
62
63
GpuBuffer2D
() :
img
(NULL) {}
64
65
//copying is not allowed except for uninitialized image buffers
66
GpuBuffer2D
(
const
GpuBuffer2D
&
x
) {
67
assert(x.
img
== NULL);
68
img
= NULL;
69
};
70
71
void
Init
(
const
ImageT
&
image
)
72
{
73
assert(
img
== NULL);
74
this->
width
= image.
getWidth
();
75
this->
height
= image.
getHeight
();
76
try
{
77
img
=
new
PixelT
[
width
*
height
];
78
}
catch
(...) {
79
throw
LSST_EXCEPT
(pexExcept::MemoryError,
"GpuBuffer2D:Init - not enough memory"
);
80
}
81
82
//copy input image data to buffer
83
for
(
int
i = 0; i <
height
; ++i) {
84
typename
ImageT::x_iterator
inPtr = image.
x_at
(0, i);
85
PixelT
* imageDataPtr =
img
+ i *
width
;
86
87
for
(
typename
ImageT::x_iterator
cnvEnd = inPtr + width; inPtr != cnvEnd;
88
++inPtr, ++imageDataPtr) {
89
*imageDataPtr = *inPtr;
90
}
91
}
92
}
93
94
void
Init
(
int
width
,
int
height
) {
95
assert(
img
== NULL);
96
this->width =
width
;
97
this->height =
height
;
98
try
{
99
img
=
new
PixelT
[width*
height
];
100
}
catch
(...) {
101
throw
LSST_EXCEPT
(pexExcept::MemoryError,
"GpuBuffer2D:Init - not enough memory"
);
102
}
103
}
104
105
GpuBuffer2D
(
const
ImageT
&
image
) {
106
img
= NULL;
107
Init
(image);
108
}
109
110
GpuBuffer2D
(
int
width
,
int
height
) {
111
img
= NULL;
112
Init
(width, height);
113
}
114
115
~GpuBuffer2D
() {
116
delete
[]
img
;
117
}
118
119
int
Size
()
const
{
120
return
width
*
height
;
121
}
122
123
PixelT
*
GetImgLinePtr
(
int
y
) {
124
assert(
img
!= NULL);
125
assert(y >= 0 && y <
height
);
126
return
&
img
[
width
*
y
];
127
}
128
const
PixelT
*
GetImgLinePtr
(
int
y
)
const
{
129
assert(
img
!= NULL);
130
assert(y >= 0 && y <
height
);
131
return
&
img
[
width
*
y
];
132
}
133
PixelT
&
Pixel
(
int
x
,
int
y
) {
134
assert(
img
!= NULL);
135
assert(x >= 0 && x <
width
);
136
assert(y >= 0 && y <
height
);
137
return
img
[x+ y*
width
];
138
}
139
const
PixelT
&
Pixel
(
int
x
,
int
y
)
const
{
140
assert(
img
!= NULL);
141
assert(x >= 0 && x <
width
);
142
assert(y >= 0 && y <
height
);
143
return
img
[x+ y*
width
];
144
}
145
146
void
CopyFromBuffer
(
const
GpuBuffer2D<PixelT>
& buffer,
int
startX,
int
startY)
147
{
148
assert(
img
!= NULL);
149
for
(
int
i = 0; i <
height
; ++i) {
150
PixelT
* inPtr = startX + buffer.
GetImgLinePtr
(i + startY);
151
PixelT
* outPtr = buffer.
GetImgLinePtr
(i);
152
for
(
int
j = 0; j <
width
; j++) {
153
*outPtr = *inPtr;
154
inPtr++;
155
outPtr++;
156
}
157
}
158
}
159
160
void
CopyToImage
(
ImageT
outImage,
int
startX,
int
startY)
161
{
162
assert(
img
!= NULL);
163
for
(
int
i = 0; i <
height
; ++i) {
164
PixelT
* outPtrImg = &
img
[
width
*i];
165
166
for
(
typename
ImageT::x_iterator
cnvPtr = outImage.
x_at
(startX, i + startY),
167
cnvEnd = cnvPtr +
width
; cnvPtr != cnvEnd; ++cnvPtr ) {
168
*cnvPtr = *outPtrImg;
169
++outPtrImg;
170
}
171
}
172
}
173
174
};
175
176
}
177
}
178
}
179
}
//namespace lsst::afw::math::detail ends
180
y
int y
Definition:
GaussianCentroid.cc:36
lsst::afw::gpu::detail::GpuBuffer2D
Class for representing an image or 2D array in general)
Definition:
GpuBuffer2D.h:54
lsst::afw::gpu::detail::GpuBuffer2D::CopyFromBuffer
void CopyFromBuffer(const GpuBuffer2D< PixelT > &buffer, int startX, int startY)
Definition:
GpuBuffer2D.h:146
lsst::afw::image::ImageBase::x_at
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
Definition:
Image.h:329
lsst::ip::diffim::detail::PixelT
float PixelT
Definition:
AssessSpatialKernelVisitor.cc:209
lsst::afw::image::ImageBase::x_iterator
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition:
Image.h:151
lsst::afw::gpu::detail::GpuBuffer2D::width
int width
Definition:
GpuBuffer2D.h:60
lsst::afw::gpu::detail::GpuBuffer2D::ImageT
lsst::afw::image::Image< PixelT > ImageT
Definition:
GpuBuffer2D.h:57
image
table::Key< table::Array< Kernel::Pixel > > image
Definition:
FixedKernel.cc:117
lsst::afw::gpu::detail::GpuBuffer2D::height
int height
Definition:
GpuBuffer2D.h:61
lsst::afw::gpu::detail::GpuBuffer2D::Init
void Init(int width, int height)
Definition:
GpuBuffer2D.h:94
lsst::afw::gpu::detail::GpuBuffer2D::Pixel
const PixelT & Pixel(int x, int y) const
Definition:
GpuBuffer2D.h:139
lsst::afw::gpu::detail::GpuBuffer2D::CopyToImage
void CopyToImage(ImageT outImage, int startX, int startY)
Definition:
GpuBuffer2D.h:160
lsst::afw::image::ImageBase::getHeight
int getHeight() const
Return the number of rows in the image.
Definition:
Image.h:239
lsst::afw::gpu::detail::GpuBuffer2D::GpuBuffer2D
GpuBuffer2D(const ImageT &image)
Definition:
GpuBuffer2D.h:105
x
double x
Definition:
ChebyshevBoundedField.cc:305
lsst::afw::gpu::detail::GpuBuffer2D::img
PixelT * img
Definition:
GpuBuffer2D.h:59
lsst::afw::gpu::detail::GpuBuffer2D::Size
int Size() const
Definition:
GpuBuffer2D.h:119
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Definition:
Exception.h:46
lsst::afw::gpu::detail::GpuBuffer2D::Init
void Init(const ImageT &image)
Definition:
GpuBuffer2D.h:71
lsst::afw::gpu::detail::GpuBuffer2D::Pixel
PixelT & Pixel(int x, int y)
Definition:
GpuBuffer2D.h:133
lsst::afw::gpu::detail::GpuBuffer2D::GpuBuffer2D
GpuBuffer2D(int width, int height)
Definition:
GpuBuffer2D.h:110
lsst::afw::gpu::detail::GpuBuffer2D::GpuBuffer2D
GpuBuffer2D()
Definition:
GpuBuffer2D.h:63
lsst::afw::gpu::detail::GpuBuffer2D::GetImgLinePtr
const PixelT * GetImgLinePtr(int y) const
Definition:
GpuBuffer2D.h:128
lsst::afw::image::ImageBase::getWidth
int getWidth() const
Return the number of columns in the image.
Definition:
Image.h:237
lsst::afw::gpu::detail::GpuBuffer2D::GpuBuffer2D
GpuBuffer2D(const GpuBuffer2D &x)
Definition:
GpuBuffer2D.h:66
lsst::afw::image::Image
A class to represent a 2-dimensional array of pixels.
Definition:
Image.h:415
lsst::afw::gpu::detail::GpuBuffer2D::~GpuBuffer2D
~GpuBuffer2D()
Definition:
GpuBuffer2D.h:115
lsst::afw::gpu::detail::GpuBuffer2D::GetImgLinePtr
PixelT * GetImgLinePtr(int y)
Definition:
GpuBuffer2D.h:123
Generated on Thu Sep 24 2015 02:29:14 for LSSTApplications by
1.8.5