フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do I change a code for square gray scale image to any size RGB image?

1 回表示 (過去 30 日間)
Diptayan Dasgupta
Diptayan Dasgupta 2021 年 5 月 12 日
閉鎖済み: Rik 2021 年 5 月 12 日
I wrote a code for square grayscale image of size 512*512 image. I wanna change it to 2048*1536 RGB image.
A=imread('lena.png'); % read 512512 8bit image
A=double(A);
A=A/255;
SP=fftshift(fft2(fftshift(A)));
D=abs(SP);
D=D(129:384,129:384);
figure;imshow(A);
title('Original image')
figure;imshow(30.*mat2gray(D)); % spectrum
title('Original spectrum')
c=1:512;
r=1:512;
[C, R]=meshgrid(c, r);
CI=((R-257).^2+(C-257).^2);
filter=zeros(512,512);
% produce a high-pass filter
for a=1:512;
for b=1:512;
if CI(a,b)>=20^2; %filter diameter
filter(a,b)=0;
else
filter(a,b)=1;
end
end
end
G=abs(filter.*SP);
G=G(129:384,129:384);
figure;imshow(30.*mat2gray(G));
title('Low-pass spectrum')
SPF=SP.*filter;
E=abs(fftshift(ifft2(fftshift(SPF))));
figure;imshow(mat2gray(E));
title('Low-pass image')

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by