How to remove correct illumination band in frequency domain image?

조회 수: 2 (최근 30일)
Nayana R
Nayana R 2018년 10월 20일
댓글: Nayana R 2018년 10월 20일
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)

답변 (1개)

Image Analyst
Image Analyst 2018년 10월 20일
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
Nayana R
Nayana R 2018년 10월 20일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by