高通滤波器转换 [英] Transformation with High Pass Filter
问题描述
我在MATLAB中读取图像'abc.jpg'
并隐瞒其数据类型以使其倍增.显示图像.
将图像的大小存储在M和N中.x,y,u和v的所有循环一直运行到图像大小为止.
I Read the image 'abc.jpg'
im MATLAB and covert its data type to double.Display the image.
Store the size of image in M and N. All the loops of x, y, u and v runs till image size.
现在我想知道
1:如何将上面的输入图像乘以(-1)^x+y
以将变换居中到U = M/2 And V = N/2
.
Now I want to know
1:how Multiply the above input image by (-1)^x+y
To Center the Transform To U = M/2 And V = N/2
.
2:将其与ideal HPF(High Pass Filter) with value of D=50.
相乘,其中D是理想HPF的半径大小.
2:multiply it with ideal HPF(High Pass Filter) with value of D=50.
where D is the radius size of Ideal HPF.
与理想HPF相乘后,生成的图像将如下所示.
After Multiplying with Ideal HPF the resulting image will look like this.
推荐答案
n1=rgb2gray(imread('fin.jpg'));
imshow(n1);
F=fft2(double(n1));
%计算图像大小
[M,N]=size(F);
%Distance Radius Size
%Distance Radius Size
D0=50;
n=2;
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;
[V,U]=meshgrid(v,u);
使用距离公式计算高通滤波器的%Distance
%Distance Calculation for High Pass Filter using Distance Formula
D=sqrt(U.^2+V.^2);
H=double(D>D0);
subplot(2,1,1);
imshow(fftshift(H));
G=H.*F;
g=real(ifft2(double(G)));
[a,b]=size(g);
for x=1:a
for y=1:b
sharpen_image(x,y)=(g(x,y))*(-1)^((x)+(y));
end
end
figure
imshow(sharpen_image);
输出
这篇关于高通滤波器转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!