% ============================================================================= % Math 336 - Image Processing - Laboratory 3 % % A matlab script for seperating the homomorphic I and r. % % Marty Kandes % Department of Physics % San Diego State University % Fall 2008 % ----------------------------------------------------------------------------- clear all; close all; clc; f = imread('homomorphic.jpg'); f = rgb2gray(f); f = mat2gray(f); g = log(1+f); M = size(g,1); N = size(g,2); G = fft2(g,M,N); G = fftshift(G); H = G; K = G; for I = 1:M for J = 1:uint8((N-15)/2) H(I,J) = 0; end; for J = uint8((N+15)/2):N H(I,J) = 0; end; end; for I = 1:M for J = 1:uint8((N-31)/2) K(I,J) = 0; end; for J = uint8((N-28)/2):uint8((N+28)/2) K(I,J) = 0; end; for J = uint8((N+32)/2):N K(I,J) = 0; end; end; figure; imshow(mat2gray(log(1+abs(H)))); figure; imshow(mat2gray(log(1+abs(K)))); H = ifftshift(H); K = ifftshift(K); h = ifft2(H); k = ifft2(K); h = real(h); k = real(k); h = exp(h); k = exp(k); h = mat2gray(h); k = mat2gray(k); figure; imshow(h); figure; imshow(k); imwrite(h,'illumination.jpg','jpg'); imwrite(k,'reflectance.jpg','jpg');