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 #ifdef __WXMAC__
24 #include "panoinc_WX.h"
25 #include "panoinc.h"
26 #endif
27 
28 #include "ChoosyRemapper.h"
29 #include "ViewState.h"
30 #include "TexCoordRemapper.h"
31 #include "VertexCoordRemapper.h"
32 
34  HuginBase::SrcPanoImage * image, VisualizationState *visualization_state)
35  : MeshRemapper(m_pano, image, visualization_state)
36 {
39 }
40 
42 {
44 }
45 
47 {
49  // have a look at the output mode, find those where the poles cause problems
50  // with the vetex remapper.
52  switch (opts->getProjection())
53  {
54  // the 'stretchy poles' cases.
61 // FIXME ARCHITECTURAL is top MILLER and bottom LAMBERT. Will need different remapper for top and bottom half
62 // currently the least distorted result is by treating it like a 'stretchy pole'
64  // the circular ones are especially important, they tend to stretch the
65  // area over the pole covers over the entire image, it is difficult to
66  // correct those.
75  // Add any projections where the poles maps to a big set of points here.
79  // check for pole crossing
80  {
81  bool pole = false;
83  // get the pole in image coordinates
86  double img_x, img_y;
87  transform.transformImgCoord(img_x, img_y,
88  info->GetNorthPoleX(),
89  info->GetNorthPoleY());
90  if ( img_y > 0.0 && img_y < height
91  && img_x > 0.0 && img_x < width)
92  {
93  pole = true; // it covers this pole
94  }
95  if (opts->getProjection() ==
97  {
98  // always use a TexCoordRemapper for Alber's equal area conic.
99  pole = true;
100  // FIXME This is not sutible for panoramas containing many small
101  // images. To detect the poles in Alber's Equal area conic
102  // projetion, we need to account for their movement with
103  // changing parameters. Also the 180 degree seam goes at a
104  // funny angle, and we need to account for this.
105  }
106  if (!pole)
107  {
108  // check the other pole
109  transform.transformImgCoord(img_x, img_y,
110  info->GetSouthPoleX(),
111  info->GetSouthPoleY());
112  if ( img_y > 0.0 && img_y < height
113  && img_x > 0.0 && img_x < width)
114  {
115  pole = true; // it covers this pole.
116  }
117  }
118  if (pole)
119  {
120  // the VertexCoordRemapper doesn't fair well with images where
121  // a single point on an image covers a range on the output.
122  // Use the TexCoordRemmaper instead.
123  if (selection != REMAP_TEX)
124  {
126  if (selected_remapper)
127  {
128  delete selected_remapper;
129  selected_remapper = 0;
130  }
132  image,
134  }
135  break;
136  }
137  // not breking to get a VertexCoordRemapper.
138  }
139  default:
140  // A VertexCoordRemapper is generally the best. Create a new one
141  // if we do not already have one.
142  if (selection != REMAP_VERTEX)
143  {
145  if (selected_remapper)
146  {
147  delete selected_remapper;
148  selected_remapper = 0;
149  }
151  image,
153  }
154  break;
155  }
156  // now we get the selected remapper to actually do the work.
158 }
159 
161 {
162  // just use the remapper created already:
164 }
165 
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