Code covered by the BSD License  

Highlights from
Stereo testbed v0.1

image thumbnail
from Stereo testbed v0.1 by Raul Correal
Testbed for analysis, evaluation and comparison of stereo matching algorithm.

homofil2Wrapper(image, RGBVHS, d, n, rL, rH)
%
% Wrapper: Raul Correal
% (raulcorreal@hotmail.com)
% 
% MATLAB code that performs Homomorphic filtering, Using Butterworth
% High Pass Filter for performing filtering.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function im_e = homofil2Wrapper(image, RGBVHS, d, n, rL, rH)

	if (ndims(image) > 2)

		% RGB image
		if (RGBVHS) == 1

			% Work in RGB space
            R = image(:,:,1);
            G = image(:,:,2);
            B = image(:,:,3);

            im_e(:,:,1) = homofil2(R, d, n, rL, rH);
            im_e(:,:,2) = homofil2(G, d, n, rL, rH);
            im_e(:,:,3) = homofil2(B, d, n, rL, rH);
            
            im_e = uint8(im_e);

		elseif (RGBVHS) == 2

			% Work in HSV space
			B = rgb2hsv(image);
			V = B(:,:,3);
			H = homofil2(V, d, n, rL, rH);
			B(:,:,3) = mat2gray(H);

            im_e = uint8((hsv2rgb(B)).*255);
		end

	else

		% Gray image
		im_e = homofil2(image, d, n, rL, rH);

	end


end

function im_e = homofil2(image, d, n, alphaL, aplhaH)

im = image;

if (ndims(image) > 2)
  im=rgb2gray(im);
end

im=double(im);

[r c]=size(im);

%%%%%%%%%% Butterworth high pass filter %%%%%%%%%%%%%%

A=zeros(r,c);
H=zeros(r,c);

for i=1:r
    for j=1:c
        A(i,j)=(((i-r/2).^2+(j-c/2).^2)).^(.5);
        H(i,j)=1/(1+((d/A(i,j))^(2*n)));
    end
end

%%%%%%%%%%%%%Using it for my application as homomorphic filtering is
%%%%%%%%%%%%%application specific, taking the value of alphaL and alphaH
%%%%%%%%%%%%%values accordingly.
%alphaL=.0999;
%aplhaH=1.01;
H=((aplhaH-alphaL).*H)+alphaL;
H=1-H;
%%%%%log of image
im_l=log2(1+im);
%%%%%DFT of logged image
im_f=fft2(im_l);
%%%%%Filter Applying DFT image
im_nf=H.*im_f;
%%%%Inverse DFT of filtered image
im_n=ifft2(im_nf);

im_a=abs(im_n);

%%%%%Inverse log 
im_e=exp(im_a);

%im_e = mat2gray(im_e);
%im_e = imadjust(im_e, [], [min(min(im)) max(max(im))]);


% subplot(1,2,2);
%subplot(122)
%imshow((im_e),[])

% figure
% imshow(H)

end

Contact us