Commit 2c6f707b authored by Bellaktris's avatar Bellaktris

fixed some errors

parent f86e3156
......@@ -43,9 +43,15 @@
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <limits>
template <typename Tp> static inline int min_idx(std::vector <Tp> vec)
namespace xphotoInternal
{
template <typename Tp> static int min_idx(std::vector <Tp> vec)
{
return int( std::min_element(vec.begin(), vec.end()) - vec.begin() );
}
......@@ -61,4 +67,6 @@ static inline int hamming_length(int x)
return res;
}
#endif /* __ALGO_HPP__ */
\ No newline at end of file
}
#endif /* __ALGO_HPP__ */
......@@ -40,9 +40,12 @@
#ifndef __ANNF_HPP__
#define __ANNF_HPP__
#include <vector>
#include "algo.hpp"
namespace xphotoInternal
{
static void plusToMinusUpdate(const cv::Mat &current, cv::Mat &next, const int dx, const int dy)
{
for (int i = 0; i < next.rows; ++i)
......@@ -123,4 +126,6 @@ static void getWHSeries(const cv::Mat &src, cv::Mat &dst, const int nProjections
cv::merge(projections, dst);
}
#endif /* __ANNF_HPP__ */
\ No newline at end of file
}
#endif /* __ANNF_HPP__ */
......@@ -177,4 +177,4 @@ namespace cv
img.convertTo( dst, src.type() );
}
}
\ No newline at end of file
}
......@@ -78,8 +78,8 @@ private:
TWeight weight;
};
std::vector<Vtx> vtcs;
std::vector<Edge> edges;
::std::vector<Vtx> vtcs;
::std::vector<Edge> edges;
TWeight flow;
};
......@@ -163,7 +163,7 @@ TWeight GCGraph<TWeight>::maxFlow()
Vtx *vtxPtr = &vtcs[0];
Edge *edgePtr = &edges[0];
std::vector<Vtx*> orphans;
::std::vector<Vtx*> orphans;
// initialize the active queue and the graph vertices
for( int i = 0; i < (int)vtcs.size(); i++ )
......
......@@ -52,11 +52,10 @@
#include "opencv2/core/types.hpp"
#include "opencv2/core/types_c.h"
namespace xphotoInternal
{
# include "photomontage.hpp"
# include "annf.hpp"
}
#include "photomontage.hpp"
#include "annf.hpp"
namespace cv
{
......@@ -64,10 +63,10 @@ namespace cv
static void shiftMapInpaint(const Mat &src, const Mat &mask, Mat &dst)
{
const int nTransform = 60; // number of dominant transforms for stitching
//const int psize = 8; // single ANNF patch size
const int psize = 8; // single ANNF patch size
/** ANNF computation **/
srand( unsigned int(time(NULL)) );
srand( unsigned(time(NULL)) );
std::vector <Matx33f> transforms; // dominant transforms
for (int i = 0; i < nTransform; ++i)
......@@ -203,4 +202,4 @@ namespace cv
break;
}
}
}
\ No newline at end of file
}
......@@ -50,6 +50,10 @@
#define GCInfinity 10*1000*1000*1000.0
namespace xphotoInternal
{
template <typename Tp> class Photomontage
{
private:
......@@ -109,10 +113,10 @@ setWeights(GCGraph <double> &graph, const cv::Point &pA, const cv::Point &pB, co
if (lA == lB)
{
/** Link from A to B **/
double weightAB = dist( images[lA].at<typename Tp>(pA),
images[lA].at<typename Tp>(pB),
images[lX].at<typename Tp>(pA),
images[lX].at<typename Tp>(pB) );
double weightAB = dist( images[lA].at<Tp>(pA),
images[lA].at<Tp>(pB),
images[lX].at<Tp>(pA),
images[lX].at<Tp>(pB) );
graph.addEdges( int(pA.y*width + pA.x), int(pB.y*width + pB.x), weightAB, weightAB);
}
else
......@@ -120,24 +124,24 @@ setWeights(GCGraph <double> &graph, const cv::Point &pA, const cv::Point &pB, co
int X = graph.addVtx();
/** Link from X to sink **/
double weightXS = dist( images[lA].at<typename Tp>(pA),
images[lA].at<typename Tp>(pB),
images[lB].at<typename Tp>(pA),
images[lB].at<typename Tp>(pB) );
double weightXS = dist( images[lA].at<Tp>(pA),
images[lA].at<Tp>(pB),
images[lB].at<Tp>(pA),
images[lB].at<Tp>(pB) );
graph.addTermWeights(X, 0, weightXS);
/** Link from A to X **/
double weightAX = dist( images[lA].at<typename Tp>(pA),
images[lA].at<typename Tp>(pB),
images[lX].at<typename Tp>(pA),
images[lX].at<typename Tp>(pB) );
double weightAX = dist( images[lA].at<Tp>(pA),
images[lA].at<Tp>(pB),
images[lX].at<Tp>(pA),
images[lX].at<Tp>(pB) );
graph.addEdges( int(pA.y*width + pA.x), X, weightAX, weightAX);
/** Link from X to B **/
double weightXB = dist( images[lX].at<typename Tp>(pA),
images[lX].at<typename Tp>(pB),
images[lB].at<typename Tp>(pA),
images[lB].at<typename Tp>(pB) );
double weightXB = dist( images[lX].at<Tp>(pA),
images[lX].at<Tp>(pB),
images[lB].at<Tp>(pA),
images[lB].at<Tp>(pB) );
graph.addEdges(X, int(pB.y*width + pB.x), weightXB, weightXB);
}
}
......@@ -151,8 +155,8 @@ singleExpansion(const int alpha)
/** Terminal links **/
for (int i = 0; i < height; ++i)
{
typename const uchar *maskAlphaRow = masks[alpha].ptr <uchar>(i);
typename const int *labelRow = (const int *) x_i.ptr <int>(i);
const uchar *maskAlphaRow = masks[alpha].ptr <uchar>(i);
const int *labelRow = (const int *) x_i.ptr <int>(i);
for (int j = 0; j < width; ++j)
graph.addTermWeights( graph.addVtx(),
......@@ -163,8 +167,8 @@ singleExpansion(const int alpha)
/** Neighbor links **/
for (int i = 0; i < height - 1; ++i)
{
typename const int *currentRow = (const int *) x_i.ptr <int>(i);
typename const int *nextRow = (const int *) x_i.ptr <int>(i + 1);
const int *currentRow = (const int *) x_i.ptr <int>(i);
const int *nextRow = (const int *) x_i.ptr <int>(i + 1);
for (int j = 0; j < width - 1; ++j)
{
......@@ -188,8 +192,8 @@ singleExpansion(const int alpha)
labelings[alpha].create( height, width, CV_32SC1 );
for (int i = 0; i < height; ++i)
{
typename const int *inRow = (const int *) x_i.ptr <int>(i);
typename int *outRow = (int *) labelings[alpha].ptr <int>(i);
const int *inRow = (const int *) x_i.ptr <int>(i);
int *outRow = (int *) labelings[alpha].ptr <int>(i);
for (int j = 0; j < width; ++j)
outRow[j] = graph.inSourceSegment(i*width + j) ? inRow[j] : alpha;
......@@ -244,11 +248,12 @@ assignResImage(cv::Mat &img)
template <typename Tp> Photomontage <Tp>::
Photomontage(const std::vector <cv::Mat> &_images, const std::vector <cv::Mat> &_masks)
:
images(_images), masks(_masks), height(int(images[0].rows)), width(int(images[0].cols)),
type(images[0].type()), x_i(height, width, CV_32SC1), channels(images[0].channels()),
lsize(int(images.size())), labelings(images.size()), distances(images.size())
{
images(_images), masks(_masks), labelings(images.size()), distances(images.size()),
height(int(images[0].rows)), width(int(images[0].cols)), type(images[0].type()),
channels(images[0].channels()), lsize(int(images.size())), x_i(height, width, CV_32SC1){
CV_Assert(images[0].depth() != CV_8U && masks[0].depth() == CV_8U);
}
#endif /* __PHOTOMONTAGE_HPP__ */
\ No newline at end of file
}
#endif /* __PHOTOMONTAGE_HPP__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment