title: Low-pass filtering a color image using the FFT and IFFT
body: <p>I am trying to apply the FFT on the color images. I extract the three components: red, green and blue then I apply <code>fft2</code> to each one separately then I applied a Gaussian filter in each plane.  Now I am trying to show the red, green and blue components after blurred. After, I apply <code>ifft2</code> to get the result.</p>
  
  <p>My problem is I see a gray image in each component.  I am trying to show just the color planes alone but my code does not work. In addition, I want to combine these three components together to return back to the full color image.  I wrote the following code below. Can anyone tell me what I'm doing wrong?</p>
  
  <pre><code>% Calculate FFT for R , G , B images
  
  I = imread ('lena.jpg'); 
  
  % Extract three images 
  Red = I (: , : , 1);
  Green = I (: , : , 2);
  Blue = I(: , : , 3);
  
  f_r = fftshift (Red); 
  F_r = fft2 (f_r); 
  
  f_g = fftshift (Green); 
  F_g = fft2 (f_g); 
  
  f_b = fftshift (Blue); 
  F_b = fft2 (f_b); 
  
  % Calculate the gaussian filter then find its FFT 
  h = fspecial( 'gaussian', [512 512] , 3.0 );
  h = fftshift (h); 
  H = fft2(h);  % Fourier Transform of 2D Gaussian 
  
  FF_R = H .* F_r ; 
  
  FF_G = H .* F_g; 
  
  FF_B = H .* F_b; 
  
  % This is to get red, green and blue images 
  b = zeros(512, 512);
  
  % Inverse IFFT _RED 
  Ir = ifftshift(FF_R);
  Irr= ifft2 (Ir); 
  I_R = fftshift (Irr); 
  IFF_R = 1 + log (abs(I_R)); 
  figure , imshow (IFF_R , [ ]); 
  
  Con1 = im2uint8(IFF_R); 
  just_red_2 = cat(3, Con1, b, b);
  figure, imshow (just_red_2); 
  
  
  % Inverse IFFT _Green 
  Ig = ifftshift(FF_G);
  Igg= ifft2 (Ig); 
  I_G = fftshift (Igg); 
  figure , imshow (1+ log(abs(I_G)), [ ]); 
  just_green_2 = cat(3, b, I_G, b);
  %figure, imshow (1 + log(abs(just_green_2)) ); 
  
  % Inverse IFFT Blue 
  Ib = ifftshift(FF_B);
  Ibb= ifft2 (Ib); 
  I_B = fftshift (Ibb); 
  figure , imshow (1+ log(abs(I_B)), [ ]); 
  just_blue_2 = cat(3, b,b, I_B);
  %figure, imshow (1 + log(abs(just_blue_2)) );
  
  
  %Combine the three component togather 
  %full_image2 = cat (3, FF_R , FF_G , FF_B);
  full_image2 = cat (3, just_red_2 (:,:,1) , just_green_2(:,:,2) , just_blue_2(:, :, 3)); 
  %full_image2 (: , : , 1) = FF_R (: , : , 1);
  %full_image2 (: , : , 2) = FF_G (: , : , 2); 
  %full_image2 (: , : , 3) = FF_B (: , : , 3); 
  Full = ifft2 ( ifftshift(full_image2));
  figure, imshow (Full , [ ])
  
  Final = fftshift(Full); 
  figure , imshow ( full_image2 ) 
  </code></pre>