Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChoosyRemapper.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
23 #include "panoinc_WX.h"
24 #include "panoinc.h"
25 
26 #include "ChoosyRemapper.h"
27 #include "ViewState.h"
28 #include "TexCoordRemapper.h"
29 #include "VertexCoordRemapper.h"
30 
32  HuginBase::SrcPanoImage * image, VisualizationState *visualization_state)
33  : MeshRemapper(m_pano, image, visualization_state)
34 {
37 }
38 
40 {
42 }
43 
45 {
47  // have a look at the output mode, find those where the poles cause problems
48  // with the vetex remapper.
50  switch (opts->getProjection())
51  {
52  // the 'stretchy poles' cases.
59 // FIXME ARCHITECTURAL is top MILLER and bottom LAMBERT. Will need different remapper for top and bottom half
60 // currently the least distorted result is by treating it like a 'stretchy pole'
62  // the circular ones are especially important, they tend to stretch the
63  // area over the pole covers over the entire image, it is difficult to
64  // correct those.
73  // Add any projections where the poles maps to a big set of points here.
77  // check for pole crossing
78  {
79  bool pole = false;
81  // get the pole in image coordinates
84  double img_x, img_y;
85  transform.transformImgCoord(img_x, img_y,
86  info->GetNorthPoleX(),
87  info->GetNorthPoleY());
88  if ( img_y > 0.0 && img_y < height
89  && img_x > 0.0 && img_x < width)
90  {
91  pole = true; // it covers this pole
92  }
93  if (opts->getProjection() ==
95  {
96  // always use a TexCoordRemapper for Alber's equal area conic.
97  pole = true;
98  // FIXME This is not sutible for panoramas containing many small
99  // images. To detect the poles in Alber's Equal area conic
100  // projetion, we need to account for their movement with
101  // changing parameters. Also the 180 degree seam goes at a
102  // funny angle, and we need to account for this.
103  }
104  if (!pole)
105  {
106  // check the other pole
107  transform.transformImgCoord(img_x, img_y,
108  info->GetSouthPoleX(),
109  info->GetSouthPoleY());
110  if ( img_y > 0.0 && img_y < height
111  && img_x > 0.0 && img_x < width)
112  {
113  pole = true; // it covers this pole.
114  }
115  }
116  if (pole)
117  {
118  // the VertexCoordRemapper doesn't fair well with images where
119  // a single point on an image covers a range on the output.
120  // Use the TexCoordRemmaper instead.
121  if (selection != REMAP_TEX)
122  {
124  if (selected_remapper)
125  {
126  delete selected_remapper;
127  selected_remapper = 0;
128  }
130  image,
132  }
133  break;
134  }
135  // not breking to get a VertexCoordRemapper.
136  }
137  default:
138  // A VertexCoordRemapper is generally the best. Create a new one
139  // if we do not already have one.
140  if (selection != REMAP_VERTEX)
141  {
143  if (selected_remapper)
144  {
145  delete selected_remapper;
146  selected_remapper = 0;
147  }
149  image,
151  }
152  break;
153  }
154  // now we get the selected remapper to actually do the work.
156 }
157 
159 {
160  // just use the remapper created already:
162 }
163 
PanoramaOptions::ProjectionFormat getProjection() const
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials...
Definition: MeshRemapper.h:43
const double GetSouthPoleX() const
A class for exchanging pointers to coordinates.
Definition: MeshRemapper.h:60
HuginBase::SrcPanoImage * image
Definition: MeshRemapper.h:85
virtual void UpdateAndResetIndex()
include file for the hugin project
virtual bool GetNextFaceCoordinates(Coords *result)=0
Get the texture and vertex coordinates for the next face.
bool GetNextFaceCoordinates(Coords *result)
Get the texture and vertex coordinates for the next face.
VisualizationState * visualization_state
Definition: MeshRemapper.h:83
const double GetNorthPoleY() const
Model for a panorama.
Definition: Panorama.h:152
ChoosyRemapper(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state)
double height
The sizes of the input images in pixels.
Definition: MeshRemapper.h:94
void UpdateAndResetIndex()
const double GetNorthPoleX() const
virtual OutputProjectionInfo * GetProjectionInfo()
Definition: ViewState.cpp:473
RemapperSelection selection
HuginBase::PTools::Transform transform
A transform to use to remap the images.
Definition: MeshRemapper.h:96
include file for the hugin project
bool transformImgCoord(double &x_dest, double &y_dest, double x_src, double y_src) const
like transform, but return image coordinates, not cartesian coordinates
virtual HuginBase::PanoramaOptions * GetOptions()
Definition: ViewState.cpp:468
double width
Definition: MeshRemapper.h:94
static void info(const char *fmt,...)
Definition: svm.cpp:95
All variables of a source image.
Definition: SrcPanoImage.h:194
Panorama image options.
const double GetSouthPoleY() const
MeshRemapper * selected_remapper
HuginBase::Panorama * m_pano
Definition: MeshRemapper.h:84
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-&gt;image transformation