From: <st...@us...> - 2009-06-26 09:59:56
|
Revision: 3968 http://hugin.svn.sourceforge.net/hugin/?rev=3968&view=rev Author: stativ Date: 2009-06-26 09:59:54 +0000 (Fri, 26 Jun 2009) Log Message: ----------- added iterations Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-25 22:34:07 UTC (rev 3967) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-26 09:59:54 UTC (rev 3968) @@ -168,129 +168,132 @@ cout << endl << "Running khan algorithm" << endl; // and we can run khan algorithm - // loop through all images - for (unsigned int i = 0; i < LabImages.size(); i++) { - if (verbosity > 1) - cout << "processing image " << i << endl; - - // vector storing pixel data - double X[5]; - double Y[5]; - // sums for eq. 6 - double wpqssum = 0; - double wpqsKhsum = 0; - // image size - int width = LabImages[i]->width(); - int height = LabImages[i]->height(); + // khan iteration + for (int it = 0; it < iterations; it++) { + // loop through all images + for (unsigned int i = 0; i < LabImages.size(); i++) { + if (verbosity > 1) + cout << "processing image " << i << endl; + + // vector storing pixel data + double X[5]; + double Y[5]; + // sums for eq. 6 + double wpqssum = 0; + double wpqsKhsum = 0; + // image size + int width = LabImages[i]->width(); + int height = LabImages[i]->height(); - // iterator to the upper left corner - FLabImage::traverser sy = LabImages[i]->upperLeft(); - // iterator to the lower right corner - FLabImage::traverser send = LabImages[i]->lowerRight(); - // iterator to the weight image left corner - FImage::traverser wy = weights[i]->upperLeft(); - // loop through the row - for (int y=1; sy.y != send.y; ++sy.y, ++wy.y, ++y) { - // iterator to the source (L*a*b image) - FLabImage::traverser sx = sy; - // iterator to the weight - FImage::traverser wx = wy; - // loop over the pixels - for (int x=1; sx.x != send.x; ++sx.x, ++wx.x, ++x) { - if (verbosity > 2) - cout << "processing pixel (" << x << "," << y << ")" << endl; - // set pixel vector - X[0] = x; // x - X[1] = y; // y - X[2] = (*sx)[0]; // L - X[3] = (*sx)[1]; // a - X[4] = (*sx)[2]; // b - - // loop through all layers - for (unsigned int j = 0; j < LabImages.size(); j++) { + // iterator to the upper left corner + FLabImage::traverser sy = LabImages[i]->upperLeft(); + // iterator to the lower right corner + FLabImage::traverser send = LabImages[i]->lowerRight(); + // iterator to the weight image left corner + FImage::traverser wy = weights[i]->upperLeft(); + // loop through the row + for (int y=1; sy.y != send.y; ++sy.y, ++wy.y, ++y) { + // iterator to the source (L*a*b image) + FLabImage::traverser sx = sy; + // iterator to the weight + FImage::traverser wx = wy; + // loop over the pixels + for (int x=1; sx.x != send.x; ++sx.x, ++wx.x, ++x) { if (verbosity > 2) - cout << "processing layer " << j << endl; - // sum of weights + cout << "processing pixel (" << x << "," << y << ")" << endl; + // set pixel vector + X[0] = x; // x + X[1] = y; // y + X[2] = (*sx)[0]; // L + X[3] = (*sx)[1]; // a + X[4] = (*sx)[2]; // b - // iterator to the current pixel - FLabImage::traverser currpx = LabImages[j]->upperLeft(); - // set it to the current position - 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-1; - currweight.x += x-1; - - // iterator to the neighbour - FLabImage::traverser neighby = currpx; - // iterator to the weight - FImage::traverser weighty = currweight; - - 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) { - neighby.y -= NEIGHB_DIST; - weighty.y -= NEIGHB_DIST; - ndy = -NEIGHB_DIST; - } - - // iterate through neighbourhoods y axis - 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+1; - // set iterator to the left border of neighborhood if it's not first column - // also set the ndx position - if (x > NEIGHB_DIST) { - neighbx.x -= NEIGHB_DIST; - weightx.x -= NEIGHB_DIST; - ndx = -NEIGHB_DIST; + // loop through all layers + for (unsigned int j = 0; j < LabImages.size(); j++) { + if (verbosity > 2) + cout << "processing layer " << j << endl; + // sum of weights + + // iterator to the current pixel + FLabImage::traverser currpx = LabImages[j]->upperLeft(); + // set it to the current position + 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-1; + currweight.x += x-1; + + // iterator to the neighbour + FLabImage::traverser neighby = currpx; + // iterator to the weight + FImage::traverser weighty = currweight; + + 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) { + neighby.y -= NEIGHB_DIST; + weighty.y -= NEIGHB_DIST; + ndy = -NEIGHB_DIST; } - // iterate through neighbourhoods x axis - int maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); - for (; ndx <= maxDistx; ++neighbx.x, ++weightx.x, ++ndx) { + + // iterate through neighbourhoods y axis + 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+1; + // set iterator to the left border of neighborhood if it's not first column + // also set the ndx position + if (x > NEIGHB_DIST) { + neighbx.x -= NEIGHB_DIST; + weightx.x -= NEIGHB_DIST; + ndx = -NEIGHB_DIST; + } + // iterate through neighbourhoods x axis + int maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); + for (; ndx <= maxDistx; ++neighbx.x, ++weightx.x, ++ndx) { + 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; + Y[1] = X[1] - ndy; + Y[2] = X[2] - (*neighbx)[0]; + Y[3] = X[3] - (*neighbx)[1]; + Y[4] = X[4] - (*neighbx)[2]; + + wpqsKhsum += (*weightx * Kh(Y)); + wpqssum += *weightx; + + maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); + } 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; - Y[1] = X[1] - ndy; - Y[2] = X[2] - (*neighbx)[0]; - Y[3] = X[3] - (*neighbx)[1]; - Y[4] = X[4] - (*neighbx)[2]; + cout << endl; - wpqsKhsum += (*weightx * Kh(Y)); - wpqssum += *weightx; - - maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); + maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); } - if (verbosity > 3) - cout << endl; - - maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); } + + if (verbosity > 2) + cout << "computing P" << endl; + // compute probability and set weight + *wx *= (float) wpqsKhsum/wpqssum; } - - if (verbosity > 2) - cout << "computing P" << endl; - // compute probability and set weight - *wx *= (float) wpqsKhsum/wpqssum; } + + // save debug weights + // save weights for testing purposes + { + char tmpfn[100]; + snprintf(tmpfn, 99, "weights_%d.tiff", i); + ImageExportInfo exWeights(tmpfn); + exportImage(srcImageRange(*weights[i]), exWeights.setPixelType("UINT8")); + } } - - // save debug weights - // save weights for testing purposes - { - char tmpfn[100]; - snprintf(tmpfn, 99, "weights_%d.tiff", i); - ImageExportInfo exWeights(tmpfn); - exportImage(srcImageRange(*weights[i]), exWeights.setPixelType("UINT8")); - } } return weights; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-26 10:29:26
|
Revision: 3969 http://hugin.svn.sourceforge.net/hugin/?rev=3969&view=rev Author: stativ Date: 2009-06-26 10:29:24 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Copy previous weights Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-26 09:59:54 UTC (rev 3968) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-26 10:29:24 UTC (rev 3969) @@ -170,6 +170,15 @@ // and we can run khan algorithm // khan iteration for (int it = 0; it < iterations; it++) { + // copy weights from previous iteration + if (verbosity > 1) + cout << "copying weights from previous iteration" << endl; + std::vector<FImagePtr> prevWeights; + for (unsigned int i = 0; i < weights.size(); i++) { + FImagePtr tmp(new FImage(*weights[i])); + prevWeights.push_back(tmp); + } + // loop through all images for (unsigned int i = 0; i < LabImages.size(); i++) { if (verbosity > 1) @@ -221,7 +230,7 @@ currpx.x += x-1; // current pixel in weights - FImage::traverser currweight = weights[j]->upperLeft(); + FImage::traverser currweight = prevWeights[j]->upperLeft(); // set it to the current position currweight.y += y-1; currweight.x += x-1; @@ -279,7 +288,7 @@ } if (verbosity > 2) - cout << "computing P" << endl; + cout << "computing new weight" << endl; // compute probability and set weight *wx *= (float) wpqsKhsum/wpqssum; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-26 12:06:10
|
Revision: 3971 http://hugin.svn.sourceforge.net/hugin/?rev=3971&view=rev Author: stativ Date: 2009-06-26 12:06:04 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Show iteration number Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-26 10:29:58 UTC (rev 3970) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-26 12:06:04 UTC (rev 3971) @@ -170,6 +170,8 @@ // and we can run khan algorithm // khan iteration for (int it = 0; it < iterations; it++) { + if (verbosity > 0) + cout << "iteration " << it << endl; // copy weights from previous iteration if (verbosity > 1) cout << "copying weights from previous iteration" << endl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-30 15:38:41
|
Revision: 3976 http://hugin.svn.sourceforge.net/hugin/?rev=3976&view=rev Author: stativ Date: 2009-06-30 15:38:35 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Small change to make kdevelop quiet Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-30 11:02:52 UTC (rev 3975) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-06-30 15:38:35 UTC (rev 3976) @@ -10,6 +10,10 @@ #include <panotools/PanoToolsInterface.h> +// for snprintf +#include <cstdio> +using std::snprintf; + using std::endl; using std::cout; @@ -140,7 +144,7 @@ weights.push_back(weight); // save linear RGB for testing purposes - { + /*{ char tmpfn[100]; snprintf(tmpfn, 99, "init_linearRGB_%d.tiff", i); ImageExportInfo exWeights(tmpfn); @@ -153,10 +157,10 @@ snprintf(tmpfn, 99, "init_Lab_%d.tiff", i); ImageExportInfo exWeights(tmpfn); exportImage(srcImageRange(*LabImage), exWeights.setPixelType("UINT8")); - } + }*/ // save weights for testing purposes - { + if (debugFlags & SAVE_WEIGHTS) { char tmpfn[100]; snprintf(tmpfn, 99, "init_weights_%d.tiff", i); ImageExportInfo exWeights(tmpfn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-01 15:54:23
|
Revision: 3979 http://hugin.svn.sourceforge.net/hugin/?rev=3979&view=rev Author: stativ Date: 2009-07-01 15:54:19 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Omit pixel in the middle Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-01 10:33:52 UTC (rev 3978) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-01 15:54:19 UTC (rev 3979) @@ -277,15 +277,17 @@ cout << "(" << ndx << "," << ndy << ")"; // now we can construct pixel vector // should omit the middle pixel, ie use only neighbours - Y[0] = X[0] - ndx; - Y[1] = X[1] - ndy; - Y[2] = X[2] - (*neighbx)[0]; - Y[3] = X[3] - (*neighbx)[1]; - Y[4] = X[4] - (*neighbx)[2]; + if (ndx != ndy != 0) { + Y[0] = X[0] - ndx; + Y[1] = X[1] - ndy; + Y[2] = X[2] - (*neighbx)[0]; + Y[3] = X[3] - (*neighbx)[1]; + Y[4] = X[4] - (*neighbx)[2]; + + wpqsKhsum += (*weightx * Kh(Y)); + wpqssum += *weightx; + } - wpqsKhsum += (*weightx * Kh(Y)); - wpqssum += *weightx; - maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); } if (verbosity > 3) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-02 13:19:24
|
Revision: 3987 http://hugin.svn.sourceforge.net/hugin/?rev=3987&view=rev Author: stativ Date: 2009-07-02 13:19:21 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Bbetter default sigma value. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-02 13:18:24 UTC (rev 3986) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-02 13:19:21 UTC (rev 3987) @@ -25,7 +25,7 @@ iterations = setIterations; response = setResponse; verbosity = 0; - sigma = 1; + sigma = 50; PIPOW = sigma*std::sqrt(2*PI); denom = 1/PIPOW; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-02 18:17:29
|
Revision: 3990 http://hugin.svn.sourceforge.net/hugin/?rev=3990&view=rev Author: stativ Date: 2009-07-02 17:00:22 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Change the way how the position of neighbour pixels is computed. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-02 13:50:25 UTC (rev 3989) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-02 17:00:22 UTC (rev 3990) @@ -175,15 +175,15 @@ // iterator to the weight image left corner FImage::traverser wy = weights[i]->upperLeft(); // loop through the row - for (int y=1; sy.y != send.y; ++sy.y, ++wy.y, ++y) { + for (int y=0; sy.y != send.y; ++sy.y, ++wy.y, ++y) { // iterator to the source (L*a*b image) FLabImage::traverser sx = sy; // iterator to the weight FImage::traverser wx = wy; // loop over the pixels - for (int x=1; sx.x != send.x; ++sx.x, ++wx.x, ++x) { + for (int x=0; sx.x != send.x; ++sx.x, ++wx.x, ++x) { if (verbosity > 2) - cout << "processing pixel (" << x << "," << y << ")" << endl; + cout << "processing pixel (" << x+1 << "," << y+1 << ")" << endl; // set pixel vector X = *sx; @@ -191,49 +191,41 @@ for (unsigned int j = 0; j < LabImages.size(); j++) { if (verbosity > 2) cout << "processing layer " << j << endl; - // sum of weights - // iterator to the current pixel - FLabImage::traverser currpx = LabImages[j]->upperLeft(); - // set it to the current position - currpx.y += y-1; - currpx.x += x-1; - - // current pixel in weights - FImage::traverser currweight = prevWeights[j]->upperLeft(); - // set it to the current position - currweight.y += y-1; - currweight.x += x-1; - // iterator to the neighbour - FLabImage::traverser neighby = currpx; + FLabImage::traverser neighby = LabImages[j]->upperLeft(); // iterator to the weight - FImage::traverser weighty = currweight; - - 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) { - neighby.y -= NEIGHB_DIST; - weighty.y -= NEIGHB_DIST; - ndy = -NEIGHB_DIST; + FImage::traverser weighty = prevWeights[j]->upperLeft(); + // pixel offset + int ndy = -NEIGHB_DIST; + // move them to the upper bound + // find the best upper bound + if (y-NEIGHB_DIST < 0) { + ndy = -y; } + else { + neighby.y += y-NEIGHB_DIST; + weighty.y += y-NEIGHB_DIST; + } // iterate through neighbourhoods y axis - int maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); + int maxDisty = (height - y) > NEIGHB_DIST ? NEIGHB_DIST : (height - y-1); for (; ndy <= maxDisty; ++neighby.y, ++weighty.y, ++ndy) { FLabImage::traverser neighbx = neighby; FImage::traverser weightx = weighty; - 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) { - neighbx.x -= NEIGHB_DIST; - weightx.x -= NEIGHB_DIST; - ndx = -NEIGHB_DIST; + // pixel offset + int ndx = -NEIGHB_DIST; + // move them to the upper bound + // find the best upper bound + if (x-NEIGHB_DIST < 0) { + ndx = -x; } + else { + neighbx.x += x-NEIGHB_DIST; + weightx.x += x-NEIGHB_DIST; + } // iterate through neighbourhoods x axis - int maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); + int maxDistx = (width - x) > NEIGHB_DIST ? NEIGHB_DIST : (width - x-1); for (; ndx <= maxDistx; ++neighbx.x, ++weightx.x, ++ndx) { if (verbosity > 3) cout << "(" << ndx << "," << ndy << ")"; @@ -244,12 +236,12 @@ wpqssum += *weightx; } - maxDistx = (width - x) >= NEIGHB_DIST ? NEIGHB_DIST : (width - x); + maxDistx = (width - x) > NEIGHB_DIST ? NEIGHB_DIST : (width - x-1); } if (verbosity > 3) cout << endl; - maxDisty = (height - y) >= NEIGHB_DIST ? NEIGHB_DIST : (height - y); + maxDisty = (height - y) > NEIGHB_DIST ? NEIGHB_DIST : (height - y-1); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-07 16:15:21
|
Revision: 4006 http://hugin.svn.sourceforge.net/hugin/?rev=4006&view=rev Author: stativ Date: 2009-07-07 16:15:20 +0000 (Tue, 07 Jul 2009) Log Message: ----------- std::abs is not necessary here Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-07 15:36:32 UTC (rev 4005) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-07 16:15:20 UTC (rev 4006) @@ -79,7 +79,7 @@ double Khan::Kh(deghosting::AlgTinyVector< float, 3 > x) { #ifdef ATAN_KH // good choice for sigma for this function is around 600 - return std::atan(-std::abs(x*x)+sigma)/PI + 0.5; + return std::atan(-(x*x)+sigma)/PI + 0.5; #else // good choice for sigma for this function is around 30 return (std::exp(-(x*x)/(2*sigma*sigma)) * denom); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-11 10:25:23
|
Revision: 4026 http://hugin.svn.sourceforge.net/hugin/?rev=4026&view=rev Author: stativ Date: 2009-07-11 10:25:21 +0000 (Sat, 11 Jul 2009) Log Message: ----------- Added message Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-11 10:25:01 UTC (rev 4025) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-11 10:25:21 UTC (rev 4026) @@ -297,7 +297,9 @@ } } } - // normalize weights + + if (verbosity > 1) + cout << "normalizing weights" << endl; for (unsigned int i=0; i<weights.size(); ++i) { transformImage(srcImageRange(*(weights[i])), destImage(*(weights[i])), NormalizeFunctor<float>(maxWeight, 255)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-17 13:24:14
|
Revision: 4050 http://hugin.svn.sourceforge.net/hugin/?rev=4050&view=rev Author: stativ Date: 2009-07-17 13:24:12 +0000 (Fri, 17 Jul 2009) Log Message: ----------- Added some code to extract probability Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-17 13:22:25 UTC (rev 4049) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-07-17 13:24:12 UTC (rev 4050) @@ -314,7 +314,10 @@ transformImage(srcImageRange(*(weights[i])), destImage(*(weights[i])), NormalizeFunctor<float>(factor)); // do this only if probabilities are requested if (flags & ADV_ONLYP) { - // TODO + FImagePtr tmpInitWeight; + FLabImagePtr null; + preprocessImage(i, tmpInitWeight, null); + combineTwoImages(srcImageRange(*(weights[i])), srcImage(*tmpInitWeight), destImage(*(weights[i])), Arg1()/Arg2()); } } return weights; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-07 11:13:49
|
Revision: 4184 http://hugin.svn.sourceforge.net/hugin/?rev=4184&view=rev Author: stativ Date: 2009-08-07 11:13:42 +0000 (Fri, 07 Aug 2009) Log Message: ----------- Remove unnecessary code that was already commented out. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-07 11:12:37 UTC (rev 4183) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-07 11:13:42 UTC (rev 4184) @@ -358,13 +358,6 @@ double factor = 255.0f/maxWeight; for (unsigned int i=0; i<weights.size(); ++i) { transformImage(srcImageRange(*(weights[i])), destImage(*(weights[i])), NormalizeFunctor<float>(factor)); - // do this only if probabilities are requested - /*if (flags & ADV_ONLYP) { - FImagePtr tmpInitWeight; - FLabImagePtr null; - preprocessImage(i, tmpInitWeight, null); - combineTwoImages(srcImageRange(*(weights[i])), srcImage(*tmpInitWeight), destImage(*(weights[i])), Arg1()/(Arg2()+Param(0.1))); - }*/ } return weights; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-08 10:54:52
|
Revision: 4186 http://hugin.svn.sourceforge.net/hugin/?rev=4186&view=rev Author: stativ Date: 2009-08-08 10:54:44 +0000 (Sat, 08 Aug 2009) Log Message: ----------- Some more work on scaling, but it still crashes :-/. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-07 18:32:50 UTC (rev 4185) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-08 10:54:44 UTC (rev 4186) @@ -194,6 +194,15 @@ const int width = weights[0]->width(); const int height = weights[0]->height(); + // if we doing scaling, we have to backup L*a*b images of original size + std::vector<FLabImagePtr> backupLab; + if (flags & ADV_MULTIRES) { + for (unsigned int i = 0; i < LabImages.size(); i++) { + // backup original size L*a*b + backupLab.push_back(LabImages[i]); + } + } + cout << endl << "Running khan algorithm" << endl; // and we can run khan algorithm // khan iteration @@ -211,24 +220,28 @@ // it would be better to use resampleImage, but it seems to be present only in VIGRA 1.6 // so let's use some of the resizeImageINTERPOLATION() functions - // compute width TODO + // compute width int resized_width = width / ( iterations/(it+1) ); - //compute height TODO + //compute height int resized_height = height / ( iterations/(it+1) ); - // destination image + // destination images FImage resizedWeight; + FLabImage resizedLab; // it's not worthy to scale to less than 100px per side if (resized_width > 100 && resized_height > 100) { // DEBUG cout << "resizing " << iterations/(it+1) << "x to: " << resized_width << " x " << resized_height << endl; // create destination image of desired size resizedWeight = FImage(Size2D(resized_width,resized_height)); + resizedLab = FLabImage(Size2D(resized_width,resized_height)); } else if (width >= 100 && height >= 100) { // resize it to the smallest value (ie 100px for the shorter side) if (width >= height) { resizedWeight = FImage(Size2D(100*width/height, 100)); + resizedLab = FLabImage(Size2D(100*width/height, 100)); } else { resizedWeight = FImage(Size2D(100, 100*height/width)); + resizedLab = FLabImage(Size2D(100, 100*height/width)); } } else { // don't scale at all @@ -236,11 +249,13 @@ goto DONTSCALE; } - // No interpolation – only for testing TODO + // No interpolation – only for testing resizeImageNoInterpolation(srcImageRange(*weights[i]), destImageRange(resizedWeight)); + resizeImageNoInterpolation(srcImageRange(*backupLab[i]), destImageRange(resizedLab)); FImagePtr tmp(new FImage(resizedWeight)); prevWeights.push_back(tmp); + LabImages[i] = FLabImagePtr(new FLabImage(resizedLab)); } else { DONTSCALE: FImagePtr tmp(new FImage(*weights[i])); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-13 09:19:36
|
Revision: 4202 http://hugin.svn.sourceforge.net/hugin/?rev=4202&view=rev Author: stativ Date: 2009-08-13 09:19:27 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Compile fix. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-13 03:06:10 UTC (rev 4201) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-13 09:19:27 UTC (rev 4202) @@ -162,7 +162,7 @@ transformImage(srcImageRange(*pInputImg, color2gray), destImage(*weight), log(Arg1()+Param(1.0f))); } else { - transformImage(srcImageRange(*pInputImg),destImage(*weight),hat); + transformImage(srcImageRange(*pInputImg),destImage(*weight),Khan::hat); } // convert from linear RGB to L*a*b // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-13 12:37:13
|
Revision: 4203 http://hugin.svn.sourceforge.net/hugin/?rev=4203&view=rev Author: stativ Date: 2009-08-13 12:37:04 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Nicer "Loading image" message. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-13 09:19:27 UTC (rev 4202) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-13 12:37:04 UTC (rev 4203) @@ -121,7 +121,7 @@ } void Khan::preprocessImage(unsigned int i, FImagePtr &weight, FLabImagePtr &LabImage) { - cout << "Loading image number " << i << endl; + cout << "Loading image " << inputFiles[i] << endl; ImageImportInfo imgInfo(inputFiles[i].c_str()); FRGBImage * pInputImg = new FRGBImage(imgInfo.size()); BImage imgAlpha(imgInfo.size()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-17 10:34:16
|
Revision: 4237 http://hugin.svn.sourceforge.net/hugin/?rev=4237&view=rev Author: stativ Date: 2009-08-17 10:33:59 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Use function calls in constructor. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-17 10:08:16 UTC (rev 4236) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-17 10:33:59 UTC (rev 4237) @@ -30,18 +30,22 @@ using std::cout; namespace deghosting { - Khan::Khan(std::vector<std::string>& setInputFiles, const uint16_t setFlags, const uint16_t setDebugFlags, - int setIterations, int setVerbosity) { - inputFiles = setInputFiles; - flags = setFlags; - debugFlags = setDebugFlags; - iterations = setIterations; - for (unsigned int i=0; i<5; i++) - response.push_back(0); - verbosity = setVerbosity; - sigma = 30; - PIPOW = sigma*std::sqrt(2*PI); - denom = 1/PIPOW; + Khan::Khan(std::vector<std::string>& newInputFiles, const uint16_t newFlags, const uint16_t newDebugFlags, + int newIterations, int newVerbosity) { + try { + loadImages(newInputFiles); + setFlags(newFlags); + setDebugFlags(newDebugFlags); + setIterationNum(newIterations); + setVerbosity(newVerbosity); + setSigma(30); + for (unsigned int i=0; i<5; i++) + response.push_back(0); + PIPOW = sigma*std::sqrt(2*PI); + denom = 1/PIPOW; + } catch (...) { + throw; + } } void Khan::loadImages(std::vector<std::string>& newInputFiles) throw(NoImages, BadDimensions) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-19 17:37:02
|
Revision: 4248 http://hugin.svn.sourceforge.net/hugin/?rev=4248&view=rev Author: stativ Date: 2009-08-19 17:36:53 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Another fix to make it behave better with HDR input. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-19 17:29:36 UTC (rev 4247) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-19 17:36:53 UTC (rev 4248) @@ -133,6 +133,9 @@ vigra::inspectImage(srcImageRange(*pInputImg), minmax); transformImage(srcImageRange(*pInputImg),destImage(*pInputImg),BrightnessContrastFunctor<RGBValue<float> >(0.45,1.0,minmax.min, minmax.max)); } + + // I don't know why, but sigma for HDR input have to approximately 10 times smaller + sigma /= 10; } // generate initial weights using hat function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-20 07:33:40
|
Revision: 4250 http://hugin.svn.sourceforge.net/hugin/?rev=4250&view=rev Author: stativ Date: 2009-08-20 07:33:33 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Minor fix to computation. Fixes compiler warning and possible errors. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-20 06:44:32 UTC (rev 4249) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-20 07:33:33 UTC (rev 4250) @@ -323,7 +323,7 @@ cout << "(" << ndx << "," << ndy << ")"; // now we can construct pixel vector // should omit the middle pixel, ie use only neighbours - if (ndx != ndy != 0) { + if ((ndx == ndy) != 0) { wpqsKhsum += (*weightx * Kh(X-(*neighbx))); wpqssum += *weightx; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-22 08:07:09
|
Revision: 4259 http://hugin.svn.sourceforge.net/hugin/?rev=4259&view=rev Author: stativ Date: 2009-08-22 08:07:01 +0000 (Sat, 22 Aug 2009) Log Message: ----------- Fixed error in condition for ommiting the middle pixel. Thanks to Andrew Mihal for noticing it. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-21 17:59:20 UTC (rev 4258) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-22 08:07:01 UTC (rev 4259) @@ -323,7 +323,7 @@ cout << "(" << ndx << "," << ndy << ")"; // now we can construct pixel vector // should omit the middle pixel, ie use only neighbours - if ((ndx == ndy) != 0) { + if (ndx != 0 || ndy != 0) { wpqsKhsum += (*weightx * Kh(X-(*neighbx))); wpqssum += *weightx; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-23 07:30:30
|
Revision: 4264 http://hugin.svn.sourceforge.net/hugin/?rev=4264&view=rev Author: stativ Date: 2009-08-23 07:30:18 +0000 (Sun, 23 Aug 2009) Log Message: ----------- Fixed problem with sigma when input is HDR. Modified Paths: -------------- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp Modified: hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp =================================================================== --- hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-23 02:47:14 UTC (rev 4263) +++ hugin/branches/gsoc2009_deghosting/src/deghosting/khan.cpp 2009-08-23 07:30:18 UTC (rev 4264) @@ -38,7 +38,16 @@ Deghosting::setDebugFlags(newDebugFlags); Deghosting::setIterationNum(newIterations); Deghosting::setVerbosity(newVerbosity); - setSigma(newSigma); + + // I don't know why, but sigma for HDR input have to approximately 10 times smaller + // FIXME: Maybe it would be better to use different sigma for different images in case both HDR and LDR are mixed + const char * fileType= ImageImportInfo(newInputFiles[0].c_str()).getFileType(); + if ( (!strcmp(fileType,"TIFF") && strcmp(fileType,"UINT8")) || !strcmp(fileType,"EXR") || !strcmp(fileType,"FLOAT")) { + setSigma(newSigma/10); + } else { + setSigma(newSigma); + } + for (unsigned int i=0; i<5; i++) Deghosting::response.push_back(0); PIPOW = sigma*std::sqrt(2*PI); @@ -56,7 +65,16 @@ Deghosting::setDebugFlags(newDebugFlags); Deghosting::setIterationNum(newIterations); Deghosting::setVerbosity(newVerbosity); - setSigma(newSigma); + + // I don't know why, but sigma for HDR input have to approximately 10 times smaller + // FIXME: Maybe it would be better to use different sigma for different images in case both HDR and LDR are mixed + const char * fileType= newInputFiles[0].getFileType(); + if ( (!strcmp(fileType,"TIFF") && strcmp(fileType,"UINT8")) || !strcmp(fileType,"EXR") || !strcmp(fileType,"FLOAT")) { + setSigma(newSigma/10); + } else { + setSigma(newSigma); + } + for (unsigned int i=0; i<5; i++) Deghosting::response.push_back(0); PIPOW = sigma*std::sqrt(2*PI); @@ -133,10 +151,8 @@ // take logarithm or gamma correction if the input images are HDR // I'm not sure if it's the right way how to // find out if they are HDR - if ( (!strcmp(imgInfo.getFileType(),"TIFF") && strcmp(imgInfo.getPixelType(),"UINT8")) || - !strcmp(imgInfo.getFileType(),"EXR") || - !strcmp(imgInfo.getPixelType(),"FLOAT")) - { + const char * fileType= imgInfo.getFileType(); + if ( (!strcmp(fileType,"TIFF") && strcmp(fileType,"UINT8")) || !strcmp(fileType,"EXR") || !strcmp(fileType,"FLOAT")) { // use gamma 2.2 if (flags & ADV_GAMMA) { // GammaFunctor is only in vigra 1.6 GRRR @@ -149,9 +165,6 @@ // take logarithm transformImage(srcImageRange(*pInputImg),destImage(*pInputImg),LogarithmFunctor<RGBValue<float> >(1.0)); } - - // I don't know why, but sigma for HDR input have to approximately 10 times smaller - sigma /= 10; } // generate initial weights using hat function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |