From 35d90f6d9ceb7fe9ac6a592a9ea4126f27951f3f Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Tue, 25 Nov 2014 14:41:05 -0500 Subject: added alternative stripe removal function --- striperemoval.m | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 striperemoval.m diff --git a/striperemoval.m b/striperemoval.m new file mode 100644 index 0000000..7563bf0 --- /dev/null +++ b/striperemoval.m @@ -0,0 +1,54 @@ +function [img_cleaned]=striperemoval(img, varargin) +% Cleans an image from the stripes produced by interference fringes. +% img - image with stripes to be removed +% varargin - not used, it is here for compatibility +% By Eugeniy E. Mikhailov 2014/11/25 +% +% be aware of "slow" spatial stripes their Fourier components will overlap with Gaussian. +% Such parallel fringes appears like strong isolated peaks in the Fourier transformed image. +% What is even nice they appear symmetrical with respect to origin but not symmetrical to +% fold +% +% ^ +% | +% * | +% | +% oOo +% -------------O0O--------------> +% oOo <- gaussian beam fft +% | +% | * <- stripe fft peak +% | +% +% +% so it easy to clean them, especially if their spatial frequency is high. +% + +img_fourier=fftshift(fft2(img)); % move to Fourier space + +imgfa= abs(img_fourier); % amplitude of Fourier components +imgfa= imgfa/max(imgfa(:)); % normalized amplitudes + +[Ny, Nx] = size (img); % image size + +mask = img_fourier.*0; +for xi = 1:Nx + % strictly speaking one of dimensions can be only half sampled due to symmetry of the mask + for yi = 1:Ny + xr = Nx - xi + 1; % reflected x + yr = Ny - yi + 1; % reflected y + mt = imgfa( yi, xi ); % test point + ms = imgfa( yr, xr ); % symmetrical point with respect to origin + mr = imgfa( yi, xr ); % symmetrical point with respect to Y axis (right) + md = imgfa( yr, xi ); % symmetrical point with respect to Y axis (down) + + m = ( mt + ms ) - ( mr + md ); % high value to the points shown at figure + m = m/max([mt, ms, mr, md]); + mask(yi,xi) = m; + end +end + +threshold = max(mask(:))/2; +mask = mask < threshold; % points due to stripes need to be removed + +img_cleaned = abs( ifft2(ifftshift(img_fourier.*mask)) ); -- cgit v1.2.3