Question

I am trying to use Accelerate framework on iphone (iOS 5.1) in order to do matrix convolution. However, when I run the function

    double *dst = calloc(2*3,sizeof(double));
    double A[6*7]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
    double B[5*5]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
    vDSP_imgfirD(A, 6, 7, B, dst, 5, 5);

I just get 0 on the result pointer. Any guess why this could happen? I have not find anywhere similar issues.

Thank you very much!

Was it helpful?

Solution

I think you are missing some understanding of convolution. I recommend looking it up on wikipedia. When you convolve a matrix with a kernel, the result is another matrix with the same size as the original matrix. Above, dst is allocating only 6 elements when your input matrix is 42 elements. dst should be 42 elements as well.

I recommend for convolution that you look at vImageConvolve_Planar8 or vImageConvolve_PlanarF. It is much better built and takes care of a lot of corner edge scenarios.

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top