Hugin trunk
0.1
Loading...
Searching...
No Matches
hugin_cpfind
localfeatures
Image.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007-2008 Anael Orlinski
3
*
4
* This file is part of Panomatic.
5
*
6
* Panomatic 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
* Panomatic 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 Panomatic; if not, write to the Free Software
18
* <http://www.gnu.org/licenses/>.
19
*/
20
21
#include <iostream>
22
#include <vector>
23
24
#include "
Image.h
"
25
26
namespace
lfeat
27
{
28
29
Image::Image
(vigra::DImage &img)
30
{
31
init
(img);
32
}
33
34
void
Image::init
(vigra::DImage &img)
35
{
36
// store values
37
_width
= img.width();
38
_height
= img.height();
39
40
// allocate the integral image data
41
_ii
=
AllocateImage
(
_width
+ 1,
_height
+ 1);
42
43
// create the integral image
44
buildIntegralImage
(img);
45
}
46
47
void
Image::clean
()
48
{
49
if
(
_ii
)
50
{
51
DeallocateImage
(
_ii
,
_height
+ 1);
52
}
53
_ii
= 0;
54
}
55
56
Image::~Image
()
57
{
58
clean
();
59
}
60
61
void
Image::buildIntegralImage
(vigra::DImage &img)
62
{
63
// to make easier the later computation, shift the image by 1 pix (x and y)
64
// so the image has a size of +1 for width and height compared to orig image.
65
66
// fill first line with zero
67
for
(
unsigned
int
i
= 0;
i
<=
_width
; ++
i
)
68
{
69
_ii
[0][
i
] = 0;
70
}
71
72
// fill first row with zero
73
for
(
unsigned
int
i
= 0;
i
<=
_height
; ++
i
)
74
{
75
_ii
[
i
][0] = 0;
76
}
77
78
// compute all the others pixels
79
for
(
unsigned
int
i
= 1;
i
<=
_height
; ++
i
)
80
for
(
unsigned
int
j
= 1;
j
<=
_width
; ++
j
)
81
{
82
_ii
[
i
][
j
] = img[
i
- 1][
j
- 1] +
_ii
[
i
- 1][
j
] +
_ii
[
i
][
j
- 1] -
_ii
[
i
- 1][
j
- 1];
83
}
84
85
}
86
87
// allocate and deallocate pixels
88
double
**
Image::AllocateImage
(
unsigned
int
iWidth
,
unsigned
int
iHeight
)
89
{
90
// create the lines holder
91
double
**
aImagePtr
=
new
double
*[
iHeight
];
92
93
// create the lines
94
for
(
unsigned
int
i
= 0;
i
<
iHeight
; ++
i
)
95
{
96
aImagePtr
[
i
] =
new
double
[
iWidth
] {};
97
}
98
99
return
aImagePtr
;
100
}
101
102
void
Image::DeallocateImage
(
double
**
iImagePtr
,
unsigned
int
iHeight
)
103
{
104
// delete the lines
105
for
(
unsigned
int
i
= 0;
i
<
iHeight
; ++
i
)
106
{
107
delete
[]
iImagePtr
[
i
];
108
}
109
110
// delete the lines holder
111
delete
[]
iImagePtr
;
112
}
113
114
}
// namespace lfeat
Image.h
lfeat::Image::_height
unsigned int _height
Definition
Image.h:74
lfeat::Image::init
void init(vigra::DImage &img)
Definition
Image.cpp:34
lfeat::Image::_ii
double ** _ii
Definition
Image.h:77
lfeat::Image::~Image
~Image()
Definition
Image.cpp:56
lfeat::Image::_width
unsigned int _width
Definition
Image.h:73
lfeat::Image::buildIntegralImage
void buildIntegralImage(vigra::DImage &img)
Definition
Image.cpp:61
lfeat::Image::clean
void clean()
Definition
Image.cpp:47
lfeat::Image::DeallocateImage
static void DeallocateImage(double **iImagePtr, unsigned int iHeight)
Definition
Image.cpp:102
lfeat::Image::Image
Image()
Definition
Image.h:36
lfeat::Image::AllocateImage
static double ** AllocateImage(unsigned int iWidth, unsigned int iHeight)
Definition
Image.cpp:88
lfeat
Definition
TestCode.h:27
threshold
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition
threshold.h:41
Generated on Sun Sep 20 2026 02:45:38 for Hugin trunk by
1.9.8