필터 지우기
필터 지우기

How can I remove the dc component from an Image?

조회 수: 9 (최근 30일)
Alessandro
Alessandro 2011년 5월 18일
I wrote this code, it is right?
subplot(2,2,1);
I = rgb2gray(imread('L3S3T2.jpg'));
imshow(I);
FT = fft2(I);
FT(1,1) = 0;
subplot(2,2,3);
I2 = ifft2(FT);
imshow(I2);

답변 (3개)

Tricky
Tricky 2012년 5월 8일
If I'm not wrong the dc component removal from image can also be done like this
I = rgb2gray(imread('L3S3T2.jpg'));
dc=mean2(I);
I1=I-dc;
imhsow(I1);
Can someone explain if there is any difference between the above mentioned Fourier method and this method.
  댓글 수: 2
Bjorn Gustavsson
Bjorn Gustavsson 2012년 5월 8일
Numerical precision and computation time - though the second might not be too bad...
...I can't see any reason to go through all that fft-ing just to remove the average.
Tricky
Tricky 2012년 5월 8일
but why the output images from the both methods are different

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


Ivan van der Kroon
Ivan van der Kroon 2011년 5월 18일
class input for fft2 should be double or single and you are using unit8. I get no errors, but this is probably not the fft2 you desire. Remember that fft2(I)=fft(fft(I).')
You are right though, that the (1,1) element is the zero-frequency or dc. But if this is the only thing you want to do just subtract the mean.

Image Analyst
Image Analyst 2012년 5월 8일
Just subtract the mean gray level, being sure to cast the image to single to allow negative values:
meanGrayLevel = mean2(I); % This is a double.
no_DC_Image = double(I) - meanGrayLevel; % Casting I to double is necessary!!!
It's not necessary to use FFT to eliminate the DC components. But if you did want to do it that way, you'd just set the first element of the FT image to zero, and then inverse transform, like you did.

커뮤니티

더 많은 답변 보기:  Power Electronics Community

제품

Community Treasure Hunt

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

Start Hunting!

Translated by