필터 지우기
필터 지우기

high pass filter

조회 수: 5 (최근 30일)
lama riad
lama riad 2012년 2월 9일
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);

채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 9일
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.
  댓글 수: 4
Walter Roberson
Walter Roberson 2012년 2월 9일
Good point, Anton.
I usually hide in the back when signal questions are asked, as I am a few decades late in handing in my homework. Gosh, I don't remember _anything_ about that course. It's like I never took it at all...
Walter Roberson
Walter Roberson 2012년 2월 11일
Ah -- ftrans2() is only for FIR filters, but butter() is an IIR filter.
http://www.mathworks.com/help/toolbox/images/ref/ftrans2.html

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

lama riad
lama riad 2012년 2월 10일
yes the m file name is (all), I changed it to (all_registration). now i made an adjustment on the code:
I= imread('cameraman.jpg');
FA = fftshift(fft2(I));
w=0.5; % frequency normalized
N=2; %filter order
b=butter(N,w,'high');
IA=ftrans2(b);
resize_filter=imresize(IA,[512 512]);
OM=resize_filter.*abs(FA);
--------------------------------------------------------
is this correct????? I'm not that well in matlab,so i need ur help plz
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 2월 11일
I am certain that this is wrong. butter() is pretty much useless unless you have multiple outputs. The number of outputs to butter() determines the filter representation that will be output. None of the representations can be expressed through a single vector.
ftrans2() is for FIR filters, but butter() is an IIR filter.
You are assuming that ftrans2() is returning something that can be simply resized to provide a 2D filter. That isn't how filters work. _If_ you were working with an FIR filter then you would take the output of ftrans2() and use it with filter2() against the image. However, you are not working with an FIR filter, and in the time I spent looking I have not found the equivalent of a 2D filter for IIR filters.
lama riad
lama riad 2012년 2월 11일
ok I read your answers really useful :D but i don't know what to do :s

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Floating-Point to Fixed-Point Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by