Hugin trunk 0.1
Loading...
Searching...
No Matches
PreviewColorPickerTool.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
9/*
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This software is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this software. If not, see
22 * <http://www.gnu.org/licenses/>.
23 *
24 */
25
26#ifdef _WIN32
27#include "wx/msw/wrapwin.h"
28#endif
30#include <wx/platform.h>
31#include "GLPreviewFrame.h"
32#include "GLViewer.h"
33#include <huginapp/ImageCache.h>
36#include <vigra/copyimage.hxx>
37#include <vigra/inspectimage.hxx>
38
40#define ColorPickerSize 10
41
42// we want to be notified if the user click into the panorama
44{
46 helper->SetStatusMessage(_("Click on a area which should be neutral gray / white in the final panorama."));
48};
49
54
55// The user click, get the current position and update white balance
57{
58 if ( e.LeftDown() && helper->IsMouseOverPano())
59 {
61 if(m_count>0 && m_red!=0 && m_blue!=0)
62 {
64 }
65 else
66 {
67 wxBell();
68 };
69 };
70};
71
73{
74 m_red=0;
75 m_blue=0;
76 m_count=0;
78 HuginBase::UIntSet activeImages=pano->getActiveImages();
79 if(!activeImages.empty())
80 {
81 for(HuginBase::UIntSet::iterator it=activeImages.begin();it!=activeImages.end();++it)
82 {
83 //check if point is inside the image, check also all 4 corners of rectangle
86 double x;
87 double y;
88 if(trans.transformImgCoord(x,y,pos.x,pos.y))
89 {
90 vigra::Point2D imagePos(x,y);
91 if(pano->getImage(*it).isInside(imagePos) &&
92 pano->getImage(*it).isInside(imagePos + vigra::Point2D(-ColorPickerSize,-ColorPickerSize)) &&
93 pano->getImage(*it).isInside(imagePos + vigra::Point2D(-ColorPickerSize, ColorPickerSize)) &&
94 pano->getImage(*it).isInside(imagePos + vigra::Point2D( ColorPickerSize,-ColorPickerSize)) &&
95 pano->getImage(*it).isInside(imagePos + vigra::Point2D( ColorPickerSize, ColorPickerSize))
96 )
97 {
99 };
100 };
101 };
102 };
103 if(m_count>0)
104 {
107 };
108};
109
110void PreviewColorPickerTool::CalcCorrectionForImage(unsigned int i,vigra::Point2D pos)
111{
114
115 //copy only region to be inspected
116 vigra::BRGBImage tempImage(2*ColorPickerSize,2*ColorPickerSize);
117 vigra::copyImage(vigra::make_triple((*cacheImage8).upperLeft() + pos + vigra::Point2D(-ColorPickerSize,-ColorPickerSize),
118 (*cacheImage8).upperLeft() + pos + vigra::Point2D( ColorPickerSize, ColorPickerSize),
119 vigra::BRGBImage::Accessor()),
120 destImage(tempImage) );
121
122 //now apply photometric corrections
125 {
126 // select exposure and response curve for LDR output
127 std::vector<double> outLut;
131 255.0);
132 }
133 else
134 {
135 invResponse.setHDROutput(true,1.0/pow(2.0,helper->GetPanoramaPtr()->getOptions().outputExposureValue));
136 }
137 vigra::DRGBImage floatTemp(tempImage.size());
139
140 //calculate average
141 vigra::FindAverage<vigra::DRGBImage::PixelType> average;
142 vigra::inspectImage(srcImageRange(floatTemp), average);
143 //range check
144 vigra::RGBValue<double> RGBaverage=average.average();
145 if(RGBaverage[0]>2 && RGBaverage[0]<253 &&
146 RGBaverage[1]>2 && RGBaverage[1]<253 &&
147 RGBaverage[2]>2 && RGBaverage[2]<253)
148 {
151 m_count++;
152 };
153};
Contains functions to transform whole images.
#define ColorPickerSize
half size of color picker window size
GLPreview * getPreview()
void UpdateGlobalWhiteBalance(double redFactor, double blueFactor)
updates the global white balance
std::shared_ptr< vigra::BRGBImage > ImageCacheRGB8Ptr
use reference counted pointers
Definition ImageCache.h:57
static ImageCache & getInstance()
get the global ImageCache object
EntryPtr getImage(const std::string &filename)
get a image.
Holds transformations for Image -> Pano and the other way.
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
Model for a panorama.
Definition Panorama.h:153
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition Panorama.h:481
UIntSet getActiveImages() const
get active images
radiometric transformation, includes exposure, vignetting and white balance
All variables of a source image.
bool isInside(vigra::Point2D p, bool ignoreMasks=false) const
check if a coordinate is inside the source image
void Activate() override
Switch on a tool.
void CalcCorrectionForImage(unsigned int i, vigra::Point2D pos)
void Deactivate() override
Switch off a tool.
void MouseButtonEvent(wxMouseEvent &e) override
process mouse button events
void CalcCorrection(hugin_utils::FDiff2D pos)
hugin_utils::FDiff2D GetMousePanoPosition()
GLPreviewFrame * GetPreviewFrame()
Definition ToolHelper.h:139
bool IsMouseOverPano()
Definition ToolHelper.h:136
HuginBase::Panorama * GetPanoramaPtr()
void NotifyMe(Event event, Tool *tool)
void SetStatusMessage(wxString message)
ToolHelper * helper
The PreviewToolHelper that uses the same preview window and panorama as the tool should.
Definition Tool.h:109
implementation of huginApp Class
std::set< unsigned int > UIntSet
void createEMoRLUT(const std::vector< float > &params, VECTOR &lut)
Definition emor.h:44
void transformImageSpatial(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor sa, DestImageIterator dest_upperleft, DestAccessor da, Functor const &f, vigra::Diff2D ul)
Definition utils.h:725
void enforceMonotonicity(LUT &lut)
enforce monotonicity of an array (mostly used for lookup tables)
Definition lut.h:87
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