Image processing – Victor Laskin's Blog https://vitiy.info Programming, architecture and design (С++, QT, .Net/WPF, Android, iOS, NoSQL, distributed systems, mobile development, image processing, etc...) Thu, 26 Sep 2013 12:11:23 +0000 en-US hourly 1 https://wordpress.org/?v=5.4.2 Stackblur – C++ multi-threaded version of fast blur algorithm https://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/ https://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/#comments Thu, 26 Sep 2013 12:10:42 +0000 http://vitiy.info/?p=130 I found nice algorithm for blurring images – Stackblur by Mario Klingemann. It could do the job relatively fast and gives decent quality. You can check it here – web demonstration. As you can see it can be usable even in web projects.

stackblursample

As i wanted to include it to my cross-platform engine i found two c++ implementations: 

First is SSE friendly, second contains some division optimization via static tables. However, both are not using all cpu cores. I took second one as foundation for my implementation, as i expected my code to work on mobile devices with no SSE support. Single-core processing of 1920×1200 rgba image with 100 px radius took only 219 ms (Intel Q9550, Windows 7).

I improved stackblur code to multi-threaded version – on my quad-core cpu speed results as expected showed 4x improvement – 63ms for the same task. You can download the part my lib below and use it as a foundation to your needs.

Download multi-threaded 32bit-color (RGBA) version of StackBlur:  stackblur.cpp

I believe algorithm can be optimized even further – any suggestions are welcome.

]]>
https://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/feed/ 7