diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-09-14 19:39:14 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-09-14 19:44:13 -0400 |
commit | 3d610e3342d89ca671ad1b8868900e39b038731d (patch) | |
tree | 3a3ccc851b8f125cec3bbd249b87f3c5a77bc039 | |
parent | 9bb2cdd954b963ecaac05cde8ebffff1b3e76ac2 (diff) | |
download | beam_profiler-3d610e3342d89ca671ad1b8868900e39b038731d.tar.gz beam_profiler-3d610e3342d89ca671ad1b8868900e39b038731d.zip |
added proper comments and algorithm description for stripeeraser
-rw-r--r-- | stripeeraser.m | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/stripeeraser.m b/stripeeraser.m index b48a5b4..5d472fe 100644 --- a/stripeeraser.m +++ b/stripeeraser.m @@ -1,15 +1,28 @@ -function [immask,imfourier]=stripeeraser(img,radius,filter) -immask=fftshift(fft2(img)); +function [img_cleaned,imfourier]=stripeeraser(img,radius,threshold_power) +% Cleans an image from the stripes produced by interference fringes. +% Such parallel fringes appears like a strong peak in the Fourier transformed image. +% so it easy to clean them, especially if their spatial frequency is high. +% +% We will clean strong frequency components higher them max*10^(-threshold_power) +% by suppressing them with exponential factor which is increases with distance +% from the center i.e. zero spatial frequencies. + +immask=fftshift(fft2(img)); % move to Fourier space max1=max(immask(:)); for x=1:640 for y=1:480 d=sqrt((x-320)^2+(y-240)^2); - if d>radius %Outside the central frequency. - if abs(immask(y,x))>max1*(10^(-filter)); %The filter works like a neutral density filter. - immask(y,x)=immask(y,x)*exp(-(d/radius)^2); %Erase the frequency of the stripes. + if d>radius + % for high enough frequency components + %The filter works like a neutral density filter. + if abs(immask(y,x))>max1*(10^(-threshold_power)); + % Suppress this frequency components which are mostly stripes + % but leave untouched small sharp features of the beam + % since they are spectrally weak + immask(y,x)=immask(y,x)*exp(-(d/radius)^2); end; end; end; end; imfourier=immask; -immask=ifft2(ifftshift(immask)); +img_cleaned=ifft2(ifftshift(immask)); |