Hugin trunk 0.1
Loading...
Searching...
No Matches
OutputProjectionInfo.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
24
26{
27 proj = output;
28 // create the transformation from lat/long to the output image.
31 fake_image.setSize(vigra::Size2D(360, 180));
32 fake_image.setHFOV(360.0);
34 // sometimes we want to go back again
36 // now grab the frequently used values
37 double x, y;
38 transform.transformImgCoord(x, y, 0.0, 90.0);
39 x_add_360 = x * -2.0 + output->getSize()->x;
40 radius = -x + output->getSize()->x / 2.0;
41 transform.transformImgCoord(x, y, 180.0, 0.0);
42 y_add_360 = -y * 2.0 + output->getSize()->y;
43 north_pole_x = x;
44 north_pole_y = y;
45 transform.transformImgCoord(x, y, 180.0, 180.0);
46 south_pole_x = x;
47 south_pole_y = y;
48 transform.transformImgCoord(x, y, 180.0, 90.0);
49 middle_x = x;
50 middle_y = y;
51 transform.transformImgCoord(x, y, 120.0, 90.0);
52 lower_x = x;
53 transform.transformImgCoord(x, y, 240.0, 90.0);
54 upper_x = x;
55 transform.transformImgCoord(x, y, 180.0, 60.0);
56 lower_y = y;
57 transform.transformImgCoord(x, y, 180.0, 120.0);
58 upper_y = y;
59 switch (output->getProjection())
60 {
70 // The poles are on the sides.
71 // ...or at least they can be detected from the sides (disk-likes)
72 // I've offset the noth pole slightly as the detection rate was
73 // not 100%
74 transform.transformImgCoord(x, y, 0.5, 90.0);
75 north_pole_x = x;
76 north_pole_y = y;
77 transform.transformImgCoord(x, y, 359.5, 90.0);
78 south_pole_x = x;
79 south_pole_y = y;
80 break;
81 default:
82 break;
83 }
84}
85
86// Some of the properties defined above change with height in some projections.
87// We have to convert an output point to elevation, and then find the boundaries
88// for +/- 180 degree seam detection at that elevation.
89const double OutputProjectionInfo::GetUpperX(const double y) const
90{
91 double temp, pitch, result;
93 transform.transformImgCoord(result, temp, 240.0, pitch);
94 return result;
95}
96
97const double OutputProjectionInfo::GetLowerX(const double y) const
98{
99 double temp, pitch, result;
101 transform.transformImgCoord(result, temp, 120.0, pitch);
102 return result;
103}
104
105// correction also changes, this is needed to move the detected vertices.
106const double OutputProjectionInfo::GetXAdd360(const double y) const
107{
108 double temp, pitch, result;
110 transform.transformImgCoord(result, temp, 0.0, pitch);
111 return result * -2.0 + proj->getSize()->x;
112}
113
114
115// Use the transformations to get arbitary points.
116
118 double yaw, double pitch)
119{
121 yaw + 180.0, pitch + 90.0);
122}
123
124bool OutputProjectionInfo::ImageToAngular(double &yaw, double &pitch,
125 double image_x, double image_y)
126{
127 bool r = reverse_transform.transformImgCoord(yaw, pitch, image_x, image_y);
128 yaw -= 180.0;
129 pitch -= 90.0;
130 return r;
131}
132
bool transformImgCoord(double &x_dest, double &y_dest, double x_src, double y_src) const
like transform, but return image coordinates, not cartesian coordinates
void createTransform(const vigra::Diff2D &srcSize, VariableMap srcVars, Lens::LensProjectionFormat srcProj, const vigra::Diff2D &destSize, PanoramaOptions::ProjectionFormat destProj, const std::vector< double > &destProjParam, double destHFOV, const vigra::Diff2D &origSrcSize)
initialize pano->image transformation
void createInvTransform(const vigra::Diff2D &srcSize, VariableMap srcVars, Lens::LensProjectionFormat srcProj, const vigra::Diff2D &destSize, PanoramaOptions::ProjectionFormat destProj, const std::vector< double > &destProjParam, double destHFOV, const vigra::Diff2D &origSrcSize)
create image->pano transformation
Panorama image options.
vigra::Size2D getSize() const
get size of output image
All variables of a source image.
void setSize(vigra::Size2D val)
Set the image size in pixels.
const double GetXAdd360() const
OutputProjectionInfo(HuginBase::PanoramaOptions *output)
bool AngularToImage(double &image_x, double &image_y, double yaw, double pitch)
bool ImageToAngular(double &yaw, double &pitch, double image_x, double image_y)
HuginBase::PanoramaOptions * proj
const double GetUpperX() const
const double GetLowerX() const
HuginBase::PTools::Transform reverse_transform
HuginBase::PTools::Transform transform
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