Clear Filters
Clear Filters

How to remove correct illumination band in frequency domain image?

4 views (last 30 days)
I ran this code for x-ray medical images and get high pass filtering and low pass filtering images in MatLab R2013a to remove illumination.But I don't know how to find correct illumination band to remove.How can I find it and remove illumination by filtering?
Then I tried to convert images into spatial domain using inverse FFT function.But didn't work correctly.Can you please suggest a code for this conversion also.
img = imread('cephalogram.bmp');
img2 = imnoise(img,'salt & pepper',0.025);
img3 = img2;
for c = 1 : 3
img3(:, :, c) = medfilt2(img2(:, :, c), [5, 5]);%add median filter
end
I=rgb2gray(img3); % convert the image to grey
A = fft2(double(I)); % compute FFT of the grey image
A1=fftshift(A); % frequency scaling
% Gaussian Filter Response Calculation
[M N]=size(A); % image size
R=10; % filter size parameter
X=0:N-1;
Y=0:M-1;
[X Y]=meshgrid(X,Y);
Cx=0.5*N;
Cy=0.5*M;
Lo=exp(-((X-Cx).^2+(Y-Cy).^2)./(2*R).^2);
Hi=1-Lo; % High pass filter=1-low pass filter
% Filtered image=ifft(filter response*fft(original image))
J=A1.*Lo;
J1=ifftshift(J);
B1=ifft2(J1);
K=A1.*Hi;
K1=ifftshift(K);
B2=ifft2(K1);
%---------visualizing the results----------------------------------------------
figure(1)
imshow(I);colormap gray
title('original image','fontsize',14)
figure(2)
imshow(abs(A1),[-12 300000]), colormap gray
title('fft of original image','fontsize',14)
figure(3)
imshow(abs(B1),[12 290]), colormap gray
title('low pass filtered image','fontsize',14)
figure(4)
imshow(abs(B2),[12 290]), colormap gray
title('High pass filtered image','fontsize',14)
%%%-----------------Converting to spatial domain--------------------------------------------------------
%fftInverse = REAL_PART(FFT(ffTransform, /INVERSE))
% invimg = ifft2(A1);
%figure(7)
%imshow(abs(invimg),[12 290]), colormap gray
%title('Inverse lowpass image','fontsize',14)

Answers (1)

Image Analyst
Image Analyst on 20 Oct 2018
Generally changes in illumination / exposure are slowly varying so you'd want to use a high pass filter to remove low spatial frequencies. You can do this in the spatial, with conv2(), or Fourier domain with fft2(). Attach 'cephalogram.bmp' if you need more help.
  1 Comment
Nayana R
Nayana R on 20 Oct 2018
Thank you so much Image Analyst for your valuable answer.I want to do it in Fourier domain. How can I use fft2() to remove illumination.I am attaching my 'cephalogram.bmp'.It's resolution is 1935*2400.I reduce it to 560 pixels.Can you give me a example code for this filtering technique?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!