Speed up Matrix Addition in C#

前端 未结 15 1164
北荒
北荒 2021-02-05 22:48

I\'d like to optimize this piece of code :

public void PopulatePixelValueMatrices(GenericImage image,int Width, int Height)
{            
        for (int x = 0;         


        
15条回答
  •  失恋的感觉
    2021-02-05 23:13

    Code profiling is the best place to start.

    Matrix addition is a highly parallel operation and can be speed up by parallelizing the operation w/ multiple threads.

    I would recommend using Intels IPP library that contains threaded highly optimized API for this sort of operation. Perhaps surprisingly it's only about $100 - but would add significant complexity to your project.

    If you don't want to trouble yourself with mixed language programming and IPP, you could try out centerspace's C# math libraries. The NMath API contains easy to used, forward scaling, matrix operations.

    Paul

提交回复
热议问题