Skip to content

Commit c2fe7c7

Browse files
committed
Add speed_vibrance_algorithm
1 parent 3170300 commit c2fe7c7

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@
3131
|SSE优化+单线程|4032*3024|66.10ms|
3232
|SSE优化+4线程|4032*3024|66.20ms|
3333

34-
- speed_vibrance_algorithm.cpp 使用SSE加速自然饱和度算法。
34+
- speed_vibrance_algorithm.cpp 使用SSE加速自然饱和度算法,算法原理请看:https://www.cnblogs.com/Imageshop/p/7234463.html。速度测试结果如下:
35+
36+
|优化方式|图像分辨率 |速度|
37+
|---------|----------|-------|
38+
|C语言实现+单线程|4032*3024||
39+
|浮点数改成整形运算+单线程|4032*3024||
40+
|SSE优化+单线程|4032*3024||

speed_vibrance_algorithm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ void VibranceAlgorithm_SSE(unsigned char *Src, unsigned char *Dest, int Width, i
212212
Dest3 = _mm_or_si128(Dest3, _mm_shuffle_epi8(Green8, _mm_setr_epi8(-1, -1, 11, -1, -1, 12, -1, -1, 13, -1, -1, 14, -1, -1, 15, -1)));
213213
Dest3 = _mm_or_si128(Dest3, _mm_shuffle_epi8(Red8, _mm_setr_epi8(10, -1, -1, 11, -1, -1, 12, -1, -1, 13, -1, -1, 14, -1, -1, 15)));
214214

215-
_mm_store_si128((__m128i *)(LinePD + 0), Dest1);
216-
_mm_store_si128((__m128i *)(LinePD + 16), Dest2);
217-
_mm_store_si128((__m128i *)(LinePD + 32), Dest3);
215+
_mm_storeu_si128((__m128i *)(LinePD + 0), Dest1);
216+
_mm_storeu_si128((__m128i *)(LinePD + 16), Dest2);
217+
_mm_storeu_si128((__m128i *)(LinePD + 32), Dest3);
218218
}
219219
for (; X < Width; X ++) {
220220
int Blue, Green, Red, Max;
@@ -254,12 +254,12 @@ int main() {
254254
int Stride = Width * 3;
255255
int Radius = 11;
256256
int Adjustment = 50;
257-
/*int64 st = cvGetTickCount();
257+
int64 st = cvGetTickCount();
258258
for (int i = 0; i <50; i++) {
259259
VibranceAlgorithm_SSE(Src, Dest, Width, Height, Stride, Adjustment);
260260
}
261261
double duration = (cv::getTickCount() - st) / cv::getTickFrequency() * 20;
262-
printf("%.5f\n", duration);*/
262+
printf("%.5f\n", duration);
263263
VibranceAlgorithm_SSE(Src, Dest, Width, Height, Stride, Adjustment);
264264
Mat dst(Height, Width, CV_8UC3, Dest);
265265
imshow("origin", src);

0 commit comments

Comments
 (0)