Skip to content

Commit eb77daf

Browse files
committed
Adding suggestions by Alexander
1 parent 3a962dc commit eb77daf

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

modules/fastcv/include/opencv2/fastcv/blur.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ CV_EXPORTS_W void sepFilter2D(InputArray _src, OutputArray _dst, int ddepth, Inp
6565
* @brief Calculates the local subtractive and contrastive normalization of the image.
6666
* Each pixel of the image is normalized by the mean and standard deviation of the patch centred at the pixel.
6767
* It is optimized for Qualcomm's processors.
68-
* @param src Input image, should have one channel CV_8U or CV_32F
69-
* @param dst Output array, should be one channel, CV_8S if src of type CV_8U, or CV_32F if src of CV_32F
68+
* @param _src Input image, should have one channel CV_8U or CV_32F
69+
* @param _dst Output array, should be one channel, CV_8S if src of type CV_8U, or CV_32F if src of CV_32F
7070
* @param pSize Patch size for mean and std dev calculation
7171
* @param useStdDev If 1, bot mean and std dev will be used for normalization, if 0, only mean used
7272
*/

modules/fastcv/perf/perf_blur.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ typedef perf::TestBaseWithParam<tuple<Size, int, Size, int>> NormalizeLocalBoxPe
125125
PERF_TEST_P(NormalizeLocalBoxPerfTest, run,
126126
::testing::Combine(::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size
127127
::testing::Values(CV_8U,CV_32F), // src image depth
128-
::testing::Values(Size(3,3),Size(5,5)), // patch size
128+
::testing::Values(Size(3,3),Size(5,5)), // patch size
129129
::testing::Values(0,1) // use std dev or not
130130
)
131131
)
@@ -140,12 +140,7 @@ PERF_TEST_P(NormalizeLocalBoxPerfTest, run,
140140
RNG& rng = cv::theRNG();
141141
cvtest::randUni(rng, src, Scalar::all(0), Scalar::all(255));
142142

143-
while (next())
144-
{
145-
startTimer();
146-
cv::fastcv::normalizeLocalBox(src, dst, sz, useStdDev);
147-
stopTimer();
148-
}
143+
TEST_CYCLE() cv::fastcv::normalizeLocalBox(src, dst, sz, useStdDev);
149144

150145
SANITY_CHECK_NOTHING();
151146
}

modules/fastcv/src/blur.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void normalizeLocalBox(InputArray _src, OutputArray _dst, Size pSize, bool useSt
368368
CV_Assert(type == CV_8UC1 || type == CV_32FC1);
369369

370370
Size size = _src.size();
371-
int dst_type = type == CV_8UC1 ? CV_8SC1 : CV_32FC1;
371+
int dst_type = type == CV_8UC1 ? CV_8SC1 : CV_32FC1;
372372
_dst.create(size, dst_type);
373373

374374
Mat src = _src.getMat();

modules/fastcv/test/test_blur.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
2+
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -108,6 +108,24 @@ TEST_P(SepFilter2DTest, accuracy)
108108
EXPECT_LT(num_diff_pixels, (src.rows+src.cols)*ksize);
109109
}
110110

111+
typedef testing::TestWithParam<tuple<int>> NormalizeLocalBoxTest;
112+
113+
TEST_P(NormalizeLocalBoxTest, accuracy)
114+
{
115+
bool use_stddev = get<0>(GetParam());
116+
cv::Mat src, dst;
117+
src = imread(cvtest::findDataFile("cv/shared/baboon.png"), cv::IMREAD_GRAYSCALE);
118+
119+
cv::fastcv::normalizeLocalBox(src, dst, Size(5,5), use_stddev);
120+
Scalar s = cv::mean(dst);
121+
122+
if(use_stddev)
123+
EXPECT_LT(s[0],1);
124+
else
125+
EXPECT_LT(s[0],50);
126+
}
127+
128+
111129
INSTANTIATE_TEST_CASE_P(FastCV_Extension, GaussianBlurTest, Combine(
112130
/*image size*/ ::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p),
113131
/*image depth*/ ::testing::Values(CV_8U,CV_16S,CV_32S),
@@ -126,4 +144,7 @@ INSTANTIATE_TEST_CASE_P(FastCV_Extension, SepFilter2DTest, Combine(
126144
/*kernel size*/ Values(3, 5, 7, 9, 11)
127145
));
128146

147+
INSTANTIATE_TEST_CASE_P(FastCV_Extension, NormalizeLocalBoxTest, Values(0,1));
148+
149+
129150
}} // namespaces opencv_test, ::

0 commit comments

Comments
 (0)