faster blur [closed]
Hi,
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
guy
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
With OpenCV 3.0 you may replace
findContours
with the much faster versionconnectedComponents()
(depending on how you continue processing the contours).@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?
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.
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