mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 11:21:39 +08:00
stereo: smallRegionRemoval() is not inplace
This commit is contained in:
@@ -493,6 +493,7 @@ namespace cv
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void smallRegionRemoval(const Mat ¤tMap, int t, Mat &out)
|
void smallRegionRemoval(const Mat ¤tMap, int t, Mat &out)
|
||||||
{
|
{
|
||||||
|
CV_Assert(currentMap.data != out.data && "inplace is not supported");
|
||||||
CV_Assert(currentMap.cols == out.cols);
|
CV_Assert(currentMap.cols == out.cols);
|
||||||
CV_Assert(currentMap.rows == out.rows);
|
CV_Assert(currentMap.rows == out.rows);
|
||||||
CV_Assert(t >= 0);
|
CV_Assert(t >= 0);
|
||||||
@@ -511,16 +512,22 @@ namespace cv
|
|||||||
int speckle_size = 0;
|
int speckle_size = 0;
|
||||||
st = 0;
|
st = 0;
|
||||||
dr = 0;
|
dr = 0;
|
||||||
for (int i = 1; i < height - 1; i++)
|
for (int i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
int iw = i * width;
|
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)
|
if (map[iw + j] != 0)
|
||||||
{
|
{
|
||||||
outputMap[iw + j] = map[iw + j];
|
outputMap[iw + j] = map[iw + j];
|
||||||
}
|
}
|
||||||
else if (map[iw + j] == 0)
|
else // if (map[iw + j] == 0)
|
||||||
{
|
{
|
||||||
T nr = 1;
|
T nr = 1;
|
||||||
T avg = 0;
|
T avg = 0;
|
||||||
|
@@ -402,7 +402,7 @@ namespace cv
|
|||||||
|
|
||||||
if(params.regionRemoval == CV_SPECKLE_REMOVAL_AVG_ALGORITHM)
|
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)
|
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
|
||||||
{
|
{
|
||||||
|
@@ -697,7 +697,7 @@ namespace cv
|
|||||||
aux.create(height,width,CV_16S);
|
aux.create(height,width,CV_16S);
|
||||||
Median1x9Filter<short>(disp, aux);
|
Median1x9Filter<short>(disp, aux);
|
||||||
Median9x1Filter<short>(aux,disp);
|
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)
|
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user