mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Merge pull request #27433 from amd:fast_bilateral_simd
imgproc: Bilateral filter performance improvement #27433 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
c5bb6a014a
commit
2762ffe7cc
@@ -13,6 +13,7 @@
|
||||
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
|
||||
// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -174,8 +175,8 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
|
||||
return;
|
||||
}
|
||||
|
||||
double gauss_color_coeff = -0.5/(sigma_color*sigma_color);
|
||||
double gauss_space_coeff = -0.5/(sigma_space*sigma_space);
|
||||
float gauss_color_coeff = (float)(-0.5/(sigma_color*sigma_color));
|
||||
float gauss_space_coeff = (float)(-0.5/(sigma_space*sigma_space));
|
||||
|
||||
if( d <= 0 )
|
||||
radius = cvRound(sigma_space*1.5);
|
||||
@@ -195,15 +196,31 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
|
||||
int* space_ofs = &_space_ofs[0];
|
||||
|
||||
// initialize color-related bilateral filter coefficients
|
||||
i = 0;
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
int nlanes = VTraits<v_float32>::vlanes();
|
||||
v_float32 v_gauss_color_coeff = vx_setall_f32(gauss_color_coeff);
|
||||
float counter[16] = {0.0, 1., 2., 3., 4., 5., 6., 7.,
|
||||
8., 9., 10., 11., 12., 13., 14., 15.};
|
||||
v_float32 v_i = vx_load(counter);
|
||||
v_float32 v_inc = vx_setall_f32(float(nlanes));
|
||||
|
||||
for( i = 0; i < 256*cn; i++ )
|
||||
for( ; i < (256*cn) - nlanes; i += nlanes )
|
||||
{
|
||||
v_float32 v_color_weight = v_mul(v_mul(v_i,v_i), v_gauss_color_coeff);
|
||||
v_store(color_weight + i, v_exp(v_color_weight));
|
||||
v_i = v_add(v_i, v_inc);
|
||||
}
|
||||
#endif
|
||||
for(; i < 256*cn; i++ )
|
||||
{
|
||||
color_weight[i] = (float)std::exp(i*i*gauss_color_coeff);
|
||||
}
|
||||
|
||||
// initialize space-related bilateral filter coefficients
|
||||
for( i = -radius, maxk = 0; i <= radius; i++ )
|
||||
{
|
||||
j = -radius;
|
||||
|
||||
for( ; j <= radius; j++ )
|
||||
{
|
||||
double r = std::sqrt((double)i*i + (double)j*j);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user