1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-18 17:24:28 +08:00

stereo: smallRegionRemoval() is not inplace

This commit is contained in:
Alexander Alekhin
2020-03-22 02:18:37 +00:00
parent 21d220d658
commit 0a32fc3bb3
3 changed files with 12 additions and 5 deletions

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)
{