MATLAB: High pass filter

image processing

hi,
i want to apply a high pass filter to image in frequency domain. Here is the code:-
I= imread('cameraman.jpg');
FA = fftshift(fft2(I));
w=0.5; % cutoff frequency
N=2; %filter order
highPassFilter=butter(N,w,'high');
OM=highPassFilter(512,512).*abs(FA); % applying high-pass filter
————————————————————-
I'm getting this error:
??? Attempted to access b(512,512); index out of bounds because size(b)=[1,3].
Error in ==> all at 32
OM=b(512,512).*abs(FA);

Best Answer

Your error message does not appear to match your code.
Did you name your file "all.m" ? If so then that would interfere with the internal use of the MATLAB function named "all"
The documentation for butter indicates that the first output argument (your highPassFilter) will be a column vector of the length indicated by your first input argument (here N, value 2). It is not the filter itself, and it is not a function: it is part of the coefficients needed to construct a filter. Accessing it at (512,512) is never going to work because it will be a column vector.
Related Question