Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6729 Discussions

How to convert a 2D convolution to two 1D convolution?

dengfuqin
Beginner
1,137 Views

for example use the X direction

sobel kernel[1 2 1; 0 0 0;-1 -2 -1] , from the SVD theory ,it can be decompose as a colum vector multiply a row vector

[-0.7071 0 0.7071]' *3.4641*[-0.4082 -0.8165 -0.4082]

I first use ippiFilterColumn_8u_C3R then use ippiFilterRow_8u_C3R to realize the two 1D convolution, the resultant image is total black image because the elements of the row vector are negative. Can anybody tell me how to realize ippiFilterSobelHoriz_8u_C3R through a two 1D convolution?

I also find that a 1D convolution is slower than 2D convolution,why?

0 Kudos
2 Replies
Intel_C_Intel
Employee
1,137 Views

Hi,

You are right, theSobel kernel is separable and can be calculated by separate row and column convolution. 2D Sobel (and other fixed separable kernels) are faster because they are implemented without the intermediate image. Separate row and column 1D convolutions require such intermediate image. The other reason - convolution with the fixed kernel is faster (eg. Sobel is [1,0,-1]*[1,2,1]).

I think your black imageis theresult of two things: 8u data are numbers from 0 to 255 and the Sobel kernel contains negative elements. 8u result is saturated to [0,255] interval and all negative pixels became zeroes. To get the right result of Sobel convolution you should choose the signed output. IPP contains ippiFilterSobel*Border_8u16s and _8u8s for 1-channel data.

For 3-channel data you could use row convolution with border ippiFilterRowBorderPipeline_8u16s_C3R and column convolution ippiFilterColumnBorderPipeline_16s_C3R or ippiFilterColumnBorderPipeline_16s8s_C3R. The example of organizeing pipelined 2D convolution is in Vol 2 of IPP manual. This example use the buffer for 1 row. By extending it to several rows you can get performance close to fixed 2D convolution

Thanks,

Alexander

ippiFilterRowBorderPipeline_8u16s_C1R

0 Kudos
dengfuqin
Beginner
1,137 Views
thanks for your help
0 Kudos
Reply