0

我需要为图像中的每个像素执行计算。我目前有一个需要很长时间的双 for 循环代码。将其转换为“blockproc(I,[1 1],fun)”会加快速度吗?

谢谢!

4

1 回答 1

3

If you have access to the Parallel Computing Toolbox and R2012a or later, you can use blockproc with the 'parallel'-option. Alternatively, you can parfor the outer loop. While it's possible blockproc is still faster, you should definitely profile the two options side-by-side.

Alternatively, you may be able to achieve important speed gains by changing your algorithm - for example, break down a 2D filter into 2 1D filters, etc.


/aside: The big advantage blockproc can have over nested-loop solutions is that it can work on images that are too big to fit in RAM, i.e. it takes care of loading sub-images for you.

于 2013-01-23T12:49:27.487 回答