Search code examples
matlabimage-processingsimulinkmatlab-cvst

How to perform blurring with Simulink / Computer Vision Toolbox?


Can't find Simulink block to perform blurring. May be it is intended to construct this functionality from existing blocks?

But straight approaches failed for me.

For example, the following model

enter image description here

causes an error

The dimension dependency rule specified for 'Test_Blur/2-D Convolution' is invalid. The input port 2 cannot have a fixed-size mode.

UPDATE

Matlab contains strange, hanging-in-the-air example vipeffects_win, which contains block named Effects but it does not work out of the box due to absence of 'imgSize` function.


Solution

  • imgSize is a variable defined in the model workspace. To avoid using it, you can simply look under the mask of the Effects subsystem. It's a block composed of smaller blocks. You can navigate under its mask and extract what you need.

    Back to the original question: to blur, just use fspecial with the 2-D FIR block from the Filtering library. You can use a 2-D gaussian mask returned by the fspecial command or you can grab a 1-D filter and use the separable option on the 2-D FIR block in order to accelerate the computation since the 2-D gaussian is separable.