%
%  Read the data.
%
  filename = 'dewey_defeats_truman.jpg';
  A = imread ( filename );

  [ m, n ] = size ( A );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Image is %d by %d pixels.\n', m, n );

  imshow ( A );
  title ( 'A: Original Image' );
%
%  Convert A to numerical format.
%
  B = double ( A );
%
%  Apply Haar to columns 1 to N.
%
  S = ( B(1:2:size(B,1),:) + B(2:2:size(B,1),:) ) / sqrt ( 2.0 );
  D = ( B(1:2:size(B,1),:) - B(2:2:size(B,1),:) ) / sqrt ( 2.0 );
  B = [ S; D ];
  imshow_numeric ( B );
%
%  Apply Haar to row, concatenate rows using comma.
%
  S = ( B(:,1:2:size(B,2)) + B(:,2:2:size(B,2)) ) / sqrt ( 2.0 );
  D = ( B(:,1:2:size(B,2)) - B(:,2:2:size(B,2)) ) / sqrt ( 2.0 );
  B = [ S, D ];
  imshow_numeric ( B );
%
%  Apply Haar to columns of B, concatenate with semicolon.
%
  S = ( B(1:2:size(B,1),:) + B(2:2:size(B,1),:) ) / sqrt ( 2.0 );
  D = ( B(1:2:size(B,1),:) - B(2:2:size(B,1),:) ) / sqrt ( 2.0 );
  B = [ S; D ];
  imshow_numeric ( B );
%
%  Apply Haar to row, concatenate rows using comma.
%
  S = ( B(:,1:2:size(B,2)) + B(:,2:2:size(B,2)) ) / sqrt ( 2.0 );
  D = ( B(:,1:2:size(B,2)) - B(:,2:2:size(B,2)) ) / sqrt ( 2.0 );
  B = [ S, D ];
  imshow_numeric ( B );

