Laplacian sharpening filter in frequency domain
Hello everybody, I have written a code to do sharpening in frequency domain with Laplacian filter. The point is theLaplacian must be be between-1,1. Therefore it was divided to its max. I don’t know why it doesn’t work. I was wondering if anyone has any experience how to fix this problem? clear
close all
clc
a=imread(‘moon.tif’);
a=im2double(a);
subplot(2,3,1);
imshow(a);
title(‘Input image’);
[m,n]=size(a);
A=fft2(a);
subplot(2,3,2);
imshow(uint8(abs(A)));
title(‘F.T. of i/p without shift’);
A_shift=fftshift(A);
A_real=abs(A_shift);
subplot(2,3,3);
imshow(uint8(A_real));
title(‘F.T. of i/p after shift’);
A_high=zeros(m,n);
D=zeros(m,n);
for u=1:m
for v=1:n
H(u,v)=-4*(pi^2)*((u-(m./2))^2+(v-(n./2))^2);
end
end
% Get maximum value of Laplacian
max_val = max(abs(H),[],’all’);
% Normalize Laplacian to range [-1,1]
H_normalized = H / max_val;
% Compute inverse Fourier transform
Laplacian_inverse = ifft2((H_normalized.*A_shift));
% Get real part of Laplacian inverse
Laplacian_real = abs(Laplacian_inverse);
subplot(2,3,4);
imshow(H);
title(‘Laplacian filter’);
subplot(2,3,5);
mesh(H)
title(‘Surface plot BHPF’);
subplot(2,3,6);
imshow(uint8(Laplacian_real));
title(‘Laplacian HP filtered image’);Hello everybody, I have written a code to do sharpening in frequency domain with Laplacian filter. The point is theLaplacian must be be between-1,1. Therefore it was divided to its max. I don’t know why it doesn’t work. I was wondering if anyone has any experience how to fix this problem? clear
close all
clc
a=imread(‘moon.tif’);
a=im2double(a);
subplot(2,3,1);
imshow(a);
title(‘Input image’);
[m,n]=size(a);
A=fft2(a);
subplot(2,3,2);
imshow(uint8(abs(A)));
title(‘F.T. of i/p without shift’);
A_shift=fftshift(A);
A_real=abs(A_shift);
subplot(2,3,3);
imshow(uint8(A_real));
title(‘F.T. of i/p after shift’);
A_high=zeros(m,n);
D=zeros(m,n);
for u=1:m
for v=1:n
H(u,v)=-4*(pi^2)*((u-(m./2))^2+(v-(n./2))^2);
end
end
% Get maximum value of Laplacian
max_val = max(abs(H),[],’all’);
% Normalize Laplacian to range [-1,1]
H_normalized = H / max_val;
% Compute inverse Fourier transform
Laplacian_inverse = ifft2((H_normalized.*A_shift));
% Get real part of Laplacian inverse
Laplacian_real = abs(Laplacian_inverse);
subplot(2,3,4);
imshow(H);
title(‘Laplacian filter’);
subplot(2,3,5);
mesh(H)
title(‘Surface plot BHPF’);
subplot(2,3,6);
imshow(uint8(Laplacian_real));
title(‘Laplacian HP filtered image’); Hello everybody, I have written a code to do sharpening in frequency domain with Laplacian filter. The point is theLaplacian must be be between-1,1. Therefore it was divided to its max. I don’t know why it doesn’t work. I was wondering if anyone has any experience how to fix this problem? clear
close all
clc
a=imread(‘moon.tif’);
a=im2double(a);
subplot(2,3,1);
imshow(a);
title(‘Input image’);
[m,n]=size(a);
A=fft2(a);
subplot(2,3,2);
imshow(uint8(abs(A)));
title(‘F.T. of i/p without shift’);
A_shift=fftshift(A);
A_real=abs(A_shift);
subplot(2,3,3);
imshow(uint8(A_real));
title(‘F.T. of i/p after shift’);
A_high=zeros(m,n);
D=zeros(m,n);
for u=1:m
for v=1:n
H(u,v)=-4*(pi^2)*((u-(m./2))^2+(v-(n./2))^2);
end
end
% Get maximum value of Laplacian
max_val = max(abs(H),[],’all’);
% Normalize Laplacian to range [-1,1]
H_normalized = H / max_val;
% Compute inverse Fourier transform
Laplacian_inverse = ifft2((H_normalized.*A_shift));
% Get real part of Laplacian inverse
Laplacian_real = abs(Laplacian_inverse);
subplot(2,3,4);
imshow(H);
title(‘Laplacian filter’);
subplot(2,3,5);
mesh(H)
title(‘Surface plot BHPF’);
subplot(2,3,6);
imshow(uint8(Laplacian_real));
title(‘Laplacian HP filtered image’); frequency MATLAB Answers — New Questions