faster blur

asked 2015-06-05 15:35:07 -0500

Guyygarty gravatar image


I am writing software for real time tracking of cells flowing in a microfluidic channel. My tracking software (apparently) works fine at about 30fps but I am trying to accelerate it so I can flow the cells faster.

I ran the visual studio profiler and found that these are my main bottlenecks:

Frame[jj] = Frame[jj] - ImageBG;  //background subtraction: 7% of execution time
blur(Frame[jj], Blurred, Size(3, 3));// remove speckle noise from image: 35% of execution time
compare(Blurred, Scalar(THRESHOLD), ImageBin, CMP_GT);// 8% of execution time
findContours(ImageBin, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);//8.5% of execution time

By comparison image acquisition is only ~2% of the execution time.

The image coming from the camera is 500x1120;CV_16UC1 (which is why I use compare rather than threshold).

I would be interested in any ideas on how to make these routines (in particular blur) run faster. I do not have a GPU available on this system.

I am using Visual C++ 2013 + OpenCV2.4.10


edit retag flag offensive close merge delete



1 If you have speckle noise may be you can remove blur operation and make a loop for backgound substraction which include specke removed.

2 Blur your image with your microscope

LBerger gravatar imageLBerger ( 2015-06-06 02:01:11 -0500 )edit

With OpenCV 3.0 you may replace findContours with the much faster version connectedComponents() (depending on how you continue processing the contours).

Guanta gravatar imageGuanta ( 2015-06-06 05:44:00 -0500 )edit

@Guanta true but his problem is mainly the computationally expensive blurring filter. Like @LBerger says, why not apply the blur with the your hardware camera setup?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-07 04:18:01 -0500 )edit

Thanks, I'll look into the options in hardware but I suspect that the speckle is probably random thermal noise in the camera electronics and will not be affected by defocusing the image. The main effect is to have hundreds of extra 1- or 2-pixel contours which clog the downstream processing. @Guanta I indeed plan to eventually go to 3.0 on that system but probably not for a while.

Guyygarty gravatar imageGuyygarty ( 2015-06-07 07:23:59 -0500 )edit

If speed cells is slow then you can increase exposure time to reduce noise. You increase brightness light.

In low light you can use a butterworth filter to reduce speckle noise but it means you decrease fps.

Is spectrum light is adjust to camera Quantum efficiency spectrum?

Have you try to track cells without blurring ? Which problems appear then?

That's only idea

LBerger gravatar imageLBerger ( 2015-06-07 08:11:28 -0500 )edit