Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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