# Require explanation for Matlab freqz2

## Question

I browsed the code of the Matlab freqz2 function (to find out how it is different to simple fft2.)

First of all it rotates the impulse response of the filter:

a = rot90(a,-2); % Unrotate filter since FIR filters are rotated.


I also found reference to it in the documentation of the filter2function:

Given a matrix X and a two-dimensional FIR filter h, filter2 rotates your filter matrix 180 degrees to create a convolution kernel

I thought conv2 would do it by itself.

Then it shifts the corner to the center:

% Now circularly shift a to put the center element at the upper left
% corner.
row_indices = [center_a(1):Ny, 1:(center_a(1)-1)]';
col_indices = [center_a(2):Nx, 1:(center_a(2)-1)]';
a = a(row_indices, col_indices);


Why does freqz2 do all of that?

## Background

I need to perform 2D filtering on a FPGA over multiplication in spatial frequency domain. The coefficients are calculated in Matlab with fspecial and then I thought I would simply use fft2 to transform it to the frequency domain analogous to the elementary property $$h(t)⊶H(e^{j\omega})$$. After seeing freqz2 I wonder and want to understand, whether to recreate those steps above too. I know, I can't use freqz2, because in addition to them it returns fftshifted frequency response, while my 2D DFT is not shifted.