stereo: smallRegionRemoval() is not inplace

pull/2474/head
Alexander Alekhin 5 years ago
parent 21d220d658
commit 0a32fc3bb3
  1. 13
      modules/stereo/src/matching.hpp
  2. 2
      modules/stereo/src/stereo_binary_bm.cpp
  3. 2
      modules/stereo/src/stereo_binary_sgbm.cpp

@ -493,6 +493,7 @@ namespace cv
template <typename T>
void smallRegionRemoval(const Mat &currentMap, int t, Mat &out)
{
CV_Assert(currentMap.data != out.data && "inplace is not supported");
CV_Assert(currentMap.cols == out.cols);
CV_Assert(currentMap.rows == out.rows);
CV_Assert(t >= 0);
@ -511,16 +512,22 @@ namespace cv
int speckle_size = 0;
st = 0;
dr = 0;
for (int i = 1; i < height - 1; i++)
for (int i = 0; i < height; i++)
{
int iw = i * width;
for (int j = 1; j < width - 1; j++)
for (int j = 0; j < width; j++)
{
if (i < 1 || i >= height - 1 || j < 1 || j >= width - 1)
{
outputMap[iw + j] = 0;
continue;
}
if (map[iw + j] != 0)
{
outputMap[iw + j] = map[iw + j];
}
else if (map[iw + j] == 0)
else // if (map[iw + j] == 0)
{
T nr = 1;
T avg = 0;

@ -402,7 +402,7 @@ namespace cv
if(params.regionRemoval == CV_SPECKLE_REMOVAL_AVG_ALGORITHM)
{
smallRegionRemoval<uint8_t>(disp0,params.speckleWindowSize,disp0);
smallRegionRemoval<uint8_t>(disp0.clone(),params.speckleWindowSize,disp0);
}
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
{

@ -697,7 +697,7 @@ namespace cv
aux.create(height,width,CV_16S);
Median1x9Filter<short>(disp, aux);
Median9x1Filter<short>(aux,disp);
smallRegionRemoval<short>(disp, params.speckleWindowSize, disp);
smallRegionRemoval<short>(disp.clone(), params.speckleWindowSize, disp);
}
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
{

Loading…
Cancel
Save