Creation of an Ideal Lowpass filter.

9 visualizzazioni (ultimi 30 giorni)
Tim van Schaik
Tim van Schaik il 4 Mag 2021
Risposto: Tim van Schaik il 4 Mag 2021
So for an exercise where you have to create an ideal filter an example was given to start you up, the problem with this exercise is that the creation of this filter almost seems impossible. First I will display the code
PQ=2*size(MRI);
[U,V]=dftuv(PQ(1),PQ(2));
D=sqrt(U.^2+V.^2);
D0=0.05*PQ(2);
F=fft2(MRI,PQ(1),PQ(2));
HidealH=piecewise(D<=D0,1,D>D0,0)
Here is the function dftuv given by.
function [U, V]=dftuv(M,N);
u=0:(M-1); v=0:(N-1);
idx=find(u>M/2); u(idx)=u(idx)-M;
idy=find(v>N/2); v(idy)=v(idy)-N;
[U, V]=meshgrid(v,u);
end
The problem lies in the HidealH part as that does not seem to work,nor I have no clue how to fix it. You are comparing D0 which is just a single value to D which is a matrix of MxN size, the piecewise function does not work here and I have no clue how to fix it so that for values of D<=D0 it becomes 1 and else it become 0.
If somebody could point me in the right direction I would be eternally gratefull.

Risposte (1)

Tim van Schaik
Tim van Schaik il 4 Mag 2021
Here the live workspace is attached

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by