27#include "hugin_config.h"
67 wxXmlResource::Get()->LoadPanel(
this,
"optimize_photo_panel");
68 wxPanel *
panel =
XRCCTRL(*
this,
"optimize_photo_panel", wxPanel);
145 hugin_utils::HuginMessageBox(
_(
"The project does not contain any active images.\nPlease activate at least 2 images in the (fast) preview window.\nOptimization canceled."),
180 HuginBase::ImageVariableGroup::IVE_EMoRParams,
181 HuginBase::ImageVariableGroup::IVE_ResponseType,
182 HuginBase::ImageVariableGroup::IVE_VigCorrMode,
183 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff,
184 HuginBase::ImageVariableGroup::IVE_RadialVigCorrCenterShift
187 std::vector<PanoCommand::PanoCommand *> commands;
190 for (
size_t i = 0;
i <
lenses.getNumberOfParts();
i++)
192 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum>
links_needed;
194 for (
int v = 0;
v < 5;
v++)
196 if (!
lenses.getVarLinkedInPart(vars[
v],
i))
207 if (!commands.empty()) {
208 if (
hugin_utils::HuginMessageBox(
_(
"The same vignetting and response parameters should\nbe applied for all images of a lens.\nCurrently each image can have different parameters.\nLink parameters?"),
218 for (std::vector<PanoCommand::PanoCommand *>::iterator
it = commands.begin();
it != commands.end(); ++
it)
231 optvars =
optPano.getOptimizeVector();
233 for(
unsigned int i=0;
i<optvars.size() && !
valid;
i++)
250 std::vector<vigra_ext::PointPairRGB>
points;
257 nPoints = nPoints *
optPano.getNrOfImages();
259 std::vector<vigra::FRGBImage *>
srcImgs;
262 for (
size_t i=0;
i <
optPano.getNrOfImages();
i++)
264 ImageCache::EntryPtr e = ImageCache::getInstance().getSmallImage(
optPano.getImage(
i).getFilename());
271 vigra::FRGBImage * img =
new vigra::FRGBImage;
272 if (e->imageFloat && e->imageFloat->size().area() > 0)
274 if (e->mask->size().area() > 0)
279 vigra::inspectImageIf(srcImageRange(*img), srcImage(
maskSmall),
minmax);
286 vigra::inspectImage(srcImageRange(*img),
minmax);
293 if (e->image16 && e->image16->size().area() > 0)
297 vigra::functor::Arg1() / vigra::functor::Param(65535.0));
305 vigra::functor::Arg1() / vigra::functor::Param(255.0));
331 progress.updateDisplay(
_(
"Optimize..."));
375 catch (std::exception & error)
384 if (
hugin_utils::HuginMessageBox(wxString::Format(
_(
"Photometric optimization results:\nAverage difference (RMSE) between overlapping pixels: %.2f gray values (0..255)\n\nApply results?"), error * 255),
390 std::vector<PanoCommand::PanoCommand*>
optCommands;
430 : wxXmlResourceHandler()
441 GetPosition(), GetSize(),
declaration of main image tree control
some definitions to work with optimizer master switches
Definition of PanoOperation class.
static double calcMeanExposure(const PanoramaData &pano)
An ImageVariableGroup is a collection of image variables that can have some shared variable values.
Make an ImageVariableGroup for lenses and other common concepts.
class for storing the limits of an image used by the sampler to exclude too dark or too bright pixel
double outputExposureValue
unsigned int colorReferenceImage
const PanoramaOptions & getOptions() const
returns the options for this panorama
void addObserver(PanoramaObserver *o)
add a panorama observer.
const int getPhotometricOptimizerSwitch() const
return the photometric optimizer master switch
Panorama getSubset(const UIntSet &imgs) const
get a subset of the panorama
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer.
UIntSet getActiveImages() const
get active images
std::size_t getNrOfImages() const
number of images.
static void optimizePhotometric(PanoramaData &pano, const OptimizeVector &vars, const PointPairs &correspondences, const float imageStepSize, AppBase::ProgressDisplay *progress, double &error)
PointPairs getResultPoints()
static void smartOptimizePhotometric(PanoramaData &pano, PhotometricOptimizeMode mode, const std::vector< vigra_ext::PointPairRGB > &correspondences, const float imageStepSize, AppBase::ProgressDisplay *progress, double &error)
use various heuristics to decide what to optimize.
PhotometricOptimizeMode
local optimize definition.
the main images tree control, used on images and optimizer tabs
HuginBase::UIntSet GetSelectedImages()
returns the selected images
void SetGuiLevel(GuiLevel newSetting)
sets the GuiLevel of the control
void Init(HuginBase::Panorama *pano)
initialization, connects all control with Panorama, register observer
void SetGroupMode(GroupMode newMode)
sets the group mode to given mode
void SetOptimizerMode()
sets to control into optimizer mode
void SetDisplayMode(DisplayMode newMode)
sets the display mode to given mode
@ DISPLAY_PHOTOMETRICS_LENSES
@ DISPLAY_PHOTOMETRICS_IMAGES
void MarkActiveImages(const bool markActive)
sets the flag, if active/disabled image should be marked with different colour
static MainFrame * Get()
hack.. kind of a pseudo singleton...
const GuiLevel GetGuiLevel() const
void SetOptimizeOnlyActiveImages(const bool onlyActive)
sets the status of the "optimize only active images" menu item
virtual bool CanHandle(wxXmlNode *node)
virtual wxObject * DoCreateResource()
void runOptimizer(const HuginBase::UIntSet &img)
HuginBase::Panorama * m_pano
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
void OnClose(wxCloseEvent &e)
void OnReset(wxCommandEvent &e)
void Init(HuginBase::Panorama *pano)
virtual void panoramaChanged(HuginBase::Panorama &pano)
receives notification about panorama changes
ImagesTreeCtrl * m_lens_tree
ImagesTreeCtrl * m_images_tree
void OnCheckOnlyActiveImages(wxCommandEvent &e)
handle "only active images" checkbox
void SetGuiLevel(GuiLevel newGuiLevel)
virtual void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
receives notification about panorama changes
void SetOnlyActiveImages(const bool onlyActive)
for external setting of "only active image" checkbox
OptimizePhotometricPanel()
void OnOptimizeButton(wxCommandEvent &e)
run the optimizer
wxCheckBox * m_only_active_images_cb
virtual ~OptimizePhotometricPanel()
PanoCommand to combine other PanoCommands.
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
static GlobalCmdHist & getInstance()
Link a set of lens variables for some lens.
Base class for all panorama commands.
update variables of a group of images
virtual PanoCommand::PanoCommand * GetCommand(wxWindow *parent, HuginBase::Panorama &pano, HuginBase::UIntSet images, GuiLevel guiLevel)
returns the appropriate PanoCommand::PanoCommand to be inserted into GlobalCmdHistory,...
PanoOperation to reset image variables.
@ RESET_DIALOG_PHOTOMETRICS
helper class, it disables the control/window in the constructor and automatically enables it back in ...
#define HUGIN_PHOTOMETRIC_OPTIMIZER_NRPOINTS
#define DEBUG_ASSERT(cond)
std::vector< VariableMap > VariableMapVector
std::vector< std::set< std::string > > OptimizeVector
std::set< unsigned int > UIntSet
std::vector< LimitIntensity > LimitIntensityVector
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
void transformImage(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor src_acc, DestImageIterator dest_upperleft, DestAccessor dest_acc, const Functor &func)
void reduceToNextLevel(ImageIn &in, ImageOut &out)
include file for the hugin project
include file for the hugin project
bool set_contains(const _Container &c, const typename _Container::key_type &key)
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
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.