Hugin trunk
0.1
Loading...
Searching...
No Matches
hugin_base
algorithms
basic
CalculateOptimalScale.cpp
Go to the documentation of this file.
1
// -*- c-basic-offset: 4 -*-
26
#include "
CalculateOptimalScale.h
"
27
28
#include <
panotools/PanoToolsInterface.h
>
29
30
31
namespace
HuginBase
{
32
34
double
CalculateOptimalScale::calcOptimalScale
(
PanoramaData
&
panorama
)
35
{
36
if
(
panorama
.getNrOfImages() == 0)
37
return
1;
38
39
PanoramaOptions
opt
=
panorama
.getOptions();
40
double
scale = 0;
41
42
for
(
unsigned
i
= 0;
i
<
panorama
.getNrOfImages();
i
++) {
43
double
s
=
calcOptimalPanoScale
(
panorama
.getSrcImage(
i
),
opt
);
44
if
(scale <
s
) {
45
scale =
s
;
46
}
47
}
48
49
return
scale;
50
}
51
52
56
double
CalculateOptimalScale::calcOptimalPanoScale
(
const
SrcPanoImage
&
src
,
57
const
PanoramaOptions
&
dest
)
58
{
59
// calculate the input pixel per output pixel ratio at the panorama center.
60
61
PTools::Transform
transf
;
62
SrcPanoImage
timg
=
src
;
63
timg
.setRoll(0);
64
timg
.setPitch(0);
65
timg
.setYaw(0);
66
timg
.setX(0);
67
timg
.setY(0);
68
timg
.setZ(0);
69
transf
.createTransform(
timg
,
dest
);
70
hugin_utils::FDiff2D
imgp1
;
71
hugin_utils::FDiff2D
imgp2
;
72
73
transf
.transform(
imgp1
,
hugin_utils::FDiff2D
(0, 0));
74
transf
.transform(
imgp2
,
hugin_utils::FDiff2D
(1, 1));
75
double
dist
=
hugin_utils::norm
(
imgp2
-
imgp1
);
76
77
return
dist
/
sqrt
(2.0);
78
79
/*
80
// calculate average pixel density of each image
81
// and use the highest one to calculate the width
82
double density=0;
83
double w = imgSize.x;
84
switch (imgProj) {
85
case Lens::RECTILINEAR:
86
density = 1/RAD_TO_DEG(atan(2*tan(DEG_TO_RAD(v)/2)/w));
87
break;
88
case Lens::CIRCULAR_FISHEYE:
89
case Lens::FULL_FRAME_FISHEYE:
90
// if we assume the linear fisheye model: r = f * theta
91
// then we get the same pixel density as for cylindrical and equirect
92
case Lens::EQUIRECTANGULAR:
93
case Lens::PANORAMIC:
94
density = w / v;
95
break;
96
}
97
// TODO: use density properly based on the output projection.
98
double width = roundi(density * opt.getHFOV());
99
*/
100
}
101
102
103
}
//namespace
CalculateOptimalScale.h
PanoToolsInterface.h
HuginBase::CalculateOptimalScale::calcOptimalScale
static double calcOptimalScale(PanoramaData &panorama)
Definition
CalculateOptimalScale.cpp:34
HuginBase::CalculateOptimalScale::calcOptimalPanoScale
static double calcOptimalPanoScale(const SrcPanoImage &src, const PanoramaOptions &dest)
function to calculate the scaling factor so that the distances in the input image and panorama image ...
Definition
CalculateOptimalScale.cpp:56
HuginBase::PTools::Transform
Holds transformations for Image -> Pano and the other way.
Definition
PanoToolsInterface.h:106
HuginBase::PanoramaData
Model for a panorama.
Definition
PanoramaData.h:82
HuginBase::PanoramaOptions
Panorama image options.
Definition
PanoramaOptions.h:80
HuginBase::SrcPanoImage
All variables of a source image.
Definition
SrcPanoImage.h:195
HuginBase
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition
wxcms.cpp:39
hugin_utils::norm
double norm(T t)
Definition
hugin_math.h:187
hugin_utils::TDiff2D
Definition
hugin_math.h:83
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 Tue Sep 1 2026 20:52:06 for Hugin trunk by
1.9.8