clear all; % Setup data image_list = mGetImageFileList; zero_bin = zeros( 2^8, 2^8 ); image_total = size( image_list, 1 ); Hu0_total = 0; %image_size_total = 0; for image_count = 1:2:image_total image_l_name = deblank( image_list( image_count,: ) ) image_l = pgmRead( sprintf( '../images/%s', image_l_name ) ); image_r_name = deblank( image_list( image_count+1,: ) ) image_r = pgmRead( sprintf( '../images/%s', image_r_name ) ); [ row_total, col_total ] = size( image_l ); image_size = row_total*col_total; bin = zero_bin; for row = 1:row_total for col = 1:col_total bin_row_index = image_l( row, col )+1; bin_col_index = image_r( row, col )+1; % zero is not a valid index -> add 1 bin( bin_row_index, bin_col_index ) = bin( bin_row_index, bin_col_index ) + 1; end end % Normalize to find pdf PDF = bin / sum( sum( bin ) ); if image_count == 2 % display joint histogram for first image mPlotJointPDF( [ image_l_name ', ' image_r_name ], 'Left image pixel', [ 0:255 ], 'Right image pixel', [ 0:255 ], 'MPD', PDF ); end % x*log(x) = log(x^x) PlogP = log( PDF.^PDF)/log(2); Hu0 = -sum( sum( PlogP ) ) Normalized_Hu0 = Hu0/2 Hu0_total = Hu0_total + Hu0;%*image_size; % image_size_total = image_size_total + image_size; end % Overall statistics: fprintf( 2, 'Combined images:\n' ) % Normalize to find pdf Average_Hu0 = Hu0_total/(image_total/2) %image_size_total Normalized_Average_Hu0 = Average_Hu0/2