From: <st...@us...> - 2009-06-24 17:01:14
|
Revision: 3963 http://hugin.svn.sourceforge.net/hugin/?rev=3963&view=rev Author: stativ Date: 2009-06-24 17:01:12 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Fixed crash, but now I see that weights are not generated correctly... Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/deghosting_mask.cpp hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Added Paths: ----------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.h Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/deghosting_mask.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/deghosting_mask.cpp 2009-06-24 10:58:39 UTC (rev 3962) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/deghosting_mask.cpp 2009-06-24 17:01:12 UTC (rev 3963) @@ -65,6 +65,7 @@ uint16_t flags = 0; uint16_t debugFlags = 0; EMoR response(0.0f); + int verbosity = 0; response.resize(5); response[0] = -3.59f; response[1] = -0.93f; @@ -119,6 +120,7 @@ usage(argv[0]); return 0; case 'v': + verbosity++; break; } } @@ -138,7 +140,7 @@ deghoster = &khanDeghoster; - deghoster->setVerbosity(2); + deghoster->setVerbosity(verbosity); deghoster->createWeightMasks(); } Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-24 10:58:39 UTC (rev 3962) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-24 17:01:12 UTC (rev 3963) @@ -215,21 +215,21 @@ // iterator to the current pixel FLabImage::traverser currpx = LabImages[j]->upperLeft(); // set it to the current position - currpx.y += y; - currpx.x += x; + currpx.y += y-1; + currpx.x += x-1; // current pixel in weights FImage::traverser currweight = weights[j]->upperLeft(); // set it to the current position - currweight.y += y; - currweight.x += x; + currweight.y += y-1; + currweight.x += x-1; // iterator to the neighbour FLabImage::traverser neighby = currpx; // iterator to the weight FImage::traverser weighty = currweight; - int ndy = -y; + int ndy = -y+1; // set iterator to the upper border of neighbourhood if it's not first row // also set the ndy position if(y > NEIGHB_DIST) { @@ -239,11 +239,11 @@ } // iterate through neighbourhoods y axis - int maxDisty = (height - y) >= ndy ? NEIGHB_DIST : (height - y); + int maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); for (; ndy <= maxDisty; ++neighby.y, ++weighty.y, ++ndy) { FLabImage::traverser neighbx = neighby; FImage::traverser weightx = weighty; - int ndx = -x; + int ndx = -x+1; // set iterator to the left border of neighborhood if it's not first column // also set the ndx position if (x > NEIGHB_DIST) { @@ -252,9 +252,10 @@ ndx = -NEIGHB_DIST; } // iterate through neighbourhoods x axis - int maxDistx = (width - x) >= ndy ? NEIGHB_DIST : (width - x); + int maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); for (; ndx <= maxDistx; ++neighbx.x, ++weightx.x, ++ndx) { - //cout << "(" << ndx << "," << ndy << ")"; + if (verbosity > 3) + cout << "(" << ndx << "," << ndy << ")"; // now we can construct pixel vector // should omit the middle pixel, ie use only neighbours Y[0] = X[0] - ndx; @@ -266,11 +267,12 @@ wpqsKhsum += (*weightx * Kh(Y)); wpqssum += *weightx; - maxDistx = (width - x) >= ndy ? NEIGHB_DIST : (width - x); + maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); } - //cout << endl; + if (verbosity > 3) + cout << endl; - maxDisty = (height - y) >= ndy ? NEIGHB_DIST : (height - y); + maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); } } Added: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.h =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.h (rev 0) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.h 2009-06-24 17:01:12 UTC (rev 3963) @@ -0,0 +1,83 @@ + +#ifndef KHAN_H_ +#define KHAN_H_ + +#include "deghosting.h" + +#include <vigra/rgbvalue.hxx> + +// needed for RGB2Lab +#include <vigra/imageinfo.hxx> +#include <vigra/transformimage.hxx> +#include <vigra/colorconversions.hxx> + +// for hat function +#include <vigra/rgbvalue.hxx> + +// needed for Kh() +#define PI 3.14159265358979323846 +#define HSIZE 5 +#define H_IDENTITY // H is identity matrix + +// number of pixels to look at in all directions +// ie. 1 for neighbourhood of size 3x3, 2 for 5x5 etc. +#define NEIGHB_DIST 1 + +using namespace vigra; + +namespace deghosting +{ + typedef FVector3Image FLabImage; + typedef boost::shared_ptr<FLabImage> FLabImagePtr; + + typedef TinyVector<float,3> colorVal; + typedef std::vector<float> EMoR; + + class Khan : public Deghosting + { + public: + Khan(std::vector< std::string >& inputFiles, const uint16_t flags, const uint16_t debugFlags, int iterations, EMoR response); + std::vector<FImagePtr> createWeightMasks(); + void loadImages(std::vector<std::string>& inputFiles); + void setFlags(const uint16_t flagslags); + void setDebugFlags(const uint16_t debugFlags); + void setIterationNum(const int iterations); + void setCameraResponse(EMoR newResponse); + void setVerbosity(int verbosity); + ~Khan() {} + private: + std::vector<std::string> inputFiles; + uint16_t flags; + uint16_t debugFlags; + int iterations; + EMoR response; + int verbosity; + + // Kh() things + // bandwith matrix + double H[HSIZE]; + // (2*pi)^(5/2) + double PIPOW; + // 1/Kh denominator + double denom; + + // other necessary stuff + std::vector<FLabImagePtr> LabImages; + std::vector<FImagePtr> weights; + + /** hat function + * used for creating initial weights + */ + static inline float hat(RGBValue<float> pixel); + /** transform image using EMoR response + * @param inputFile filename of image to be transformed + * @param *pInputImg FRGBImage to be transformed + */ + void linearizeRGB(std::string, FRGBImage* pInputImg); + /** kernel function + */ + inline double Kh(double x[]); + }; +} + +#endif /* KHAN_H_ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |