## What is the Image Processing Toolbox Convention for Input to freqz2() ?

I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?

Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).

Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."

Define an input FIR filter

rng(100);

h = rand(5);

If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be

H0 = fftshift(fft2(ifftshift(h)));

In order to get the same result from freqz2(), the input has to be rotated 180 deg

H1 = freqz2(rot90(h,-2),5,5,[1 1]);

isequal(H1,H0)

Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?

Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part?I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?

Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).

Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."

Define an input FIR filter

rng(100);

h = rand(5);

If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be

H0 = fftshift(fft2(ifftshift(h)));

In order to get the same result from freqz2(), the input has to be rotated 180 deg

H1 = freqz2(rot90(h,-2),5,5,[1 1]);

isequal(H1,H0)

Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?

Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part? I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?

Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).

Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."

Define an input FIR filter

rng(100);

h = rand(5);

If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be

H0 = fftshift(fft2(ifftshift(h)));

In order to get the same result from freqz2(), the input has to be rotated 180 deg

H1 = freqz2(rot90(h,-2),5,5,[1 1]);

isequal(H1,H0)

Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?

Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part? freqz2, fir filter convention MATLAB Answers — New Questions