Commit 21d220d6 authored by Alexander Alekhin's avatar Alexander Alekhin

stereo: get rid of imageMeanKernelSize, replace with blur()

parent 7c0e6efd
...@@ -239,18 +239,5 @@ namespace cv ...@@ -239,18 +239,5 @@ namespace cv
CombinedDescriptor<1,1,1,1,ModifiedCsCensus<1> >(img1.cols, img1.rows,stride,n2,date,ModifiedCsCensus<1>(images,n2),1)); CombinedDescriptor<1,1,1,1,ModifiedCsCensus<1> >(img1.cols, img1.rows,stride,n2,date,ModifiedCsCensus<1>(images,n2),1));
} }
} }
//integral image computation used in the Mean Variation Census Transform
void imageMeanKernelSize(const Mat &image, int windowSize, Mat &cost)
{
CV_Assert(!image.empty());
CV_Assert(!cost.empty());
CV_Assert(windowSize % 2 != 0);
int win = windowSize / 2;
float scalling = ((float) 1) / (windowSize * windowSize);
int height = image.rows;
cost.setTo(0);
int *c = (int *)cost.data;
parallel_for_(Range(0, height), MeanKernelIntegralImage(image, win, scalling, c));
}
} }
} }
...@@ -245,42 +245,6 @@ namespace cv ...@@ -245,42 +245,6 @@ namespace cv
} }
} }
}; };
//!calculate the mean of every windowSizexWindwoSize block from the integral Image
//!this is a preprocessing for MV kernel
class MeanKernelIntegralImage : public ParallelLoopBody
{
private:
const Mat& img;
int windowSize;
float scalling;
int *c;
public:
MeanKernelIntegralImage(const cv::Mat &image, int window,float scale, int *cost):
img(image),windowSize(window), scalling(scale), c(cost)
{}
void operator()(const cv::Range &r) const CV_OVERRIDE
{
const int width = img.cols;
const int height = img.rows;
for (int i = r.start; i < r.end; i++)
{
int y0 = std::max(0, i - windowSize + 1);
int y1 = std::min(height - 1, i + windowSize);
int iw = i * width;
for (int j = 0; j < width; j++)
{
int x0 = std::max(0, j - windowSize + 1);
int x1 = std::min(height - 1, j + windowSize);
c[iw + j] = (int)(
(
img.at<int>(y0, x0) + img.at<int>(y0, x0) -
img.at<int>(y1, x0) - img.at<int>(y0, x1)
) * scalling);
}
}
}
};
//!implementation for the star kernel descriptor //!implementation for the star kernel descriptor
template<int num_images> template<int num_images>
class StarKernelCensus:public ParallelLoopBody class StarKernelCensus:public ParallelLoopBody
...@@ -441,8 +405,6 @@ namespace cv ...@@ -441,8 +405,6 @@ namespace cv
} }
} }
}; };
//integral image computation used in the Mean Variation Census Transform
void imageMeanKernelSize(const cv::Mat &img, int windowSize, cv::Mat &c);
} }
} }
#endif #endif
......
...@@ -384,15 +384,10 @@ namespace cv ...@@ -384,15 +384,10 @@ namespace cv
} }
else if(params.kernelType == CV_MEAN_VARIATION) else if(params.kernelType == CV_MEAN_VARIATION)
{ {
parSumsIntensityImage[0].create(left0.rows, left0.cols,CV_32SC4); Mat blurLeft; blur(left, blurLeft, Size(params.kernelSize, params.kernelSize));
parSumsIntensityImage[1].create(left0.rows, left0.cols,CV_32SC4); Mat blurRight; blur(right, blurRight, Size(params.kernelSize, params.kernelSize));
Integral[0].create(left0.rows,left0.cols,CV_32SC4); modifiedCensusTransform(left, right, params.kernelSize, censusImage[0], censusImage[1], CV_MEAN_VARIATION, 0,
Integral[1].create(left0.rows,left0.cols,CV_32SC4); blurLeft, blurRight);
integral(left, parSumsIntensityImage[0],CV_32S);
integral(right, parSumsIntensityImage[1],CV_32S);
imageMeanKernelSize(parSumsIntensityImage[0], params.kernelSize,Integral[0]);
imageMeanKernelSize(parSumsIntensityImage[1], params.kernelSize, Integral[1]);
modifiedCensusTransform(left,right,params.kernelSize,censusImage[0],censusImage[1],CV_MEAN_VARIATION,0,Integral[0], Integral[1]);
} }
else if(params.kernelType == CV_STAR_KERNEL) else if(params.kernelType == CV_STAR_KERNEL)
{ {
...@@ -502,8 +497,6 @@ namespace cv ...@@ -502,8 +497,6 @@ namespace cv
StereoBinaryBMParams params; StereoBinaryBMParams params;
Mat preFilteredImg0, preFilteredImg1, cost, dispbuf; Mat preFilteredImg0, preFilteredImg1, cost, dispbuf;
Mat slidingSumBuf; Mat slidingSumBuf;
Mat parSumsIntensityImage[2];
Mat Integral[2];
Mat censusImage[2]; Mat censusImage[2];
Mat hammingDistance; Mat hammingDistance;
Mat partialSumsLR; Mat partialSumsLR;
......
...@@ -669,15 +669,10 @@ namespace cv ...@@ -669,15 +669,10 @@ namespace cv
} }
else if(params.kernelType == CV_MEAN_VARIATION) else if(params.kernelType == CV_MEAN_VARIATION)
{ {
parSumsIntensityImage[0].create(left.rows, left.cols,CV_32SC4); Mat blurLeft; blur(left, blurLeft, Size(params.kernelSize, params.kernelSize));
parSumsIntensityImage[1].create(left.rows, left.cols,CV_32SC4); Mat blurRight; blur(right, blurRight, Size(params.kernelSize, params.kernelSize));
Integral[0].create(left.rows,left.cols,CV_32SC4); modifiedCensusTransform(left, right, params.kernelSize, censusImageLeft, censusImageRight, CV_MEAN_VARIATION, 0,
Integral[1].create(left.rows,left.cols,CV_32SC4); blurLeft, blurRight);
integral(left, parSumsIntensityImage[0],CV_32S);
integral(right, parSumsIntensityImage[1],CV_32S);
imageMeanKernelSize(parSumsIntensityImage[0], params.kernelSize,Integral[0]);
imageMeanKernelSize(parSumsIntensityImage[1], params.kernelSize, Integral[1]);
modifiedCensusTransform(left,right,params.kernelSize,censusImageLeft,censusImageRight,CV_MEAN_VARIATION,0,Integral[0], Integral[1]);
} }
else if(params.kernelType == CV_STAR_KERNEL) else if(params.kernelType == CV_STAR_KERNEL)
{ {
...@@ -800,8 +795,6 @@ namespace cv ...@@ -800,8 +795,6 @@ namespace cv
Mat partialSumsLR; Mat partialSumsLR;
Mat agregatedHammingLRCost; Mat agregatedHammingLRCost;
Mat hamDist; Mat hamDist;
Mat parSumsIntensityImage[2];
Mat Integral[2];
}; };
const char* StereoBinarySGBMImpl::name_ = "StereoBinaryMatcher.SGBM"; const char* StereoBinarySGBMImpl::name_ = "StereoBinaryMatcher.SGBM";
......
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