Tuesday, 19 May 2015

matlab - Convolution a 3-D signal with 2-D signal


I have a 3D signal $M(x,y,t)$ and I want to do convolution with signal $G(x,y)$ and $Et(t)$,


I mean, how to calculate this Convolution below in Matlab?


$$A(x,y,t)=M(x,y,t) \star G(x,y) \star Et(t)$$


In my case, $M(x,y,t)$ is a movie with $k$ frame; $x,y$ are position in image and $t$ depend on frames number and frame rate. $G(x,y)$ is a gaussian shape with $x,y$ and $Et(t)$ is a simple exponential in time.




Answer



I propose this is an abuse of notations, which can be tackled as follows: the convolution in the time dimension $t$ is independent of the one in the space dimensions $(x,y)$, in a separable way. In practice, you can convolve each 2D data $A(x,y,.)$ with $G(x,y)$, then each resulting 1D data $A'(.,.,t)$ with $Et(t)$, or in the opposite order, which is allowed due to linearity.


A cleaner version would construct the 3D operator by a tensor product operation between $G$ and $Et$, resulting in:


$$ M\ast (G\otimes Et)\,.$$


This is sometimes called a (separable) space-time filter. It is simpler to implement, supposing that the perception rules differ in space and time. However, it reached its limits in following fast motions between time frame (sometimes, non-separable filters or full 3D filters are used in video).


Basically, it combines 2D and 1D filters into a genuine 3D filter $H_{G,Et}(x,y,t)$, so that, for each $(x,y,t)$:


$$H_{G,Et}(x,y,t) = G(x,y)\cdot Et(t)\,.$$


In practice, using separability is more efficient. In Matlab, if you can load all the data, if you can for instance first 2D filter each 2D frame with $G$, then "transpose" to get the time in the first dimension, and apply:



y = filter(b,a,x)




which is vectorized, and revert to the initial data order.


Outside this natural interpretation, I consider the above abuse very abusive.


Additional reading on separability:



No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...