mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
refactored Separable Linear Filters
This commit is contained in:
@@ -65,8 +65,8 @@ void cv::gpu::CannyBuf::create(const Size& image_size, int apperture_size)
|
||||
|
||||
if (apperture_size != 3)
|
||||
{
|
||||
filterDX = createDerivFilter_GPU(CV_8UC1, CV_32S, 1, 0, apperture_size, BORDER_REPLICATE);
|
||||
filterDY = createDerivFilter_GPU(CV_8UC1, CV_32S, 0, 1, apperture_size, BORDER_REPLICATE);
|
||||
filterDX = createDerivFilter(CV_8UC1, CV_32S, 1, 0, apperture_size, false, 1, BORDER_REPLICATE);
|
||||
filterDY = createDerivFilter(CV_8UC1, CV_32S, 0, 1, apperture_size, false, 1, BORDER_REPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ void cv::gpu::Canny(const GpuMat& src, CannyBuf& buf, GpuMat& dst, double low_th
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.filterDX->apply(src, buf.dx, Rect(0, 0, src.cols, src.rows));
|
||||
buf.filterDY->apply(src, buf.dy, Rect(0, 0, src.cols, src.rows));
|
||||
buf.filterDX->apply(src, buf.dx);
|
||||
buf.filterDY->apply(src, buf.dy);
|
||||
|
||||
calcMagnitude(buf.dx, buf.dy, buf.mag, L2gradient);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace
|
||||
{
|
||||
void extractCovData(const GpuMat& src, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, int borderType, Stream& stream)
|
||||
{
|
||||
(void) buf;
|
||||
|
||||
double scale = static_cast<double>(1 << ((ksize > 0 ? ksize : 3) - 1)) * blockSize;
|
||||
|
||||
if (ksize < 0)
|
||||
@@ -83,16 +85,21 @@ namespace
|
||||
Dx.create(src.size(), CV_32F);
|
||||
Dy.create(src.size(), CV_32F);
|
||||
|
||||
Ptr<gpu::Filter> filterDx, filterDy;
|
||||
|
||||
if (ksize > 0)
|
||||
{
|
||||
Sobel(src, Dx, CV_32F, 1, 0, buf, ksize, scale, borderType, -1, stream);
|
||||
Sobel(src, Dy, CV_32F, 0, 1, buf, ksize, scale, borderType, -1, stream);
|
||||
filterDx = gpu::createSobelFilter(src.type(), CV_32F, 1, 0, ksize, scale, borderType);
|
||||
filterDy = gpu::createSobelFilter(src.type(), CV_32F, 0, 1, ksize, scale, borderType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Scharr(src, Dx, CV_32F, 1, 0, buf, scale, borderType, -1, stream);
|
||||
Scharr(src, Dy, CV_32F, 0, 1, buf, scale, borderType, -1, stream);
|
||||
filterDx = gpu::createScharrFilter(src.type(), CV_32F, 1, 0, scale, borderType);
|
||||
filterDy = gpu::createScharrFilter(src.type(), CV_32F, 0, 1, scale, borderType);
|
||||
}
|
||||
|
||||
filterDx->apply(src, Dx);
|
||||
filterDy->apply(src, Dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user