clear all; clf reset; % Setup data image_list = mGetLeftImageFileList; image_total = size( image_list, 1 ); zero_bin = zeros( 1, 2^8 ); Hu0_total = 0; %size_total = 0; for image_count = 1:image_total image_name = deblank( image_list( image_count,: ) ) image = pgmRead( sprintf( '../images/%s', image_name ) ); [ row_total, col_total ] = size( image ); image_size = row_total*col_total; bin = zero_bin; for row = 1:row_total for col = 1:col_total bin_index = image( row, col )+1; % zero index not allowed bin( bin_index ) = bin( bin_index ) + 1; end end % Normalize to find pdf PDF = bin/sum(bin); % subplot( image_total, 1, image_count ); % plot( [ 0:size( PDF, 2 )-1 ], PDF ); % axis( [ 0 255 0 0.06 ] ); % grid on; % xlabel( 'Pixel value' ); % ylabel( 'Marginal Probability Density' ); % title( image_name ); % drawnow; % x*log(x) = log(x^x) PlogP = log(PDF.^PDF)./log(2); Hu0 = -sum( PlogP ) Hu0_total = Hu0_total + Hu0;%*image_size; % size_total = size_total + image_size; end % Overall statistics: fprintf( 2, 'Combined images:' ) Average_Hu0 = Hu0_total/image_total %size_total