Contents

What pre-processing was applied to images from BSD?

function z = preprocess_image( imgfile )

Copyright Notice

%=========================================================================
%   COPYRIGHT NOTICE AND LICENSE INFO:
%
%   * Copyright (C) 2010, Gautam V. Pendse, McLean Hospital
%
%   * Matlab demo illustrating the pre-processing applied to natural images in:
%
%       Gautam V. Pendse, "PMOG: The projected mixture of Gaussians model with application to blind source separation",
%       arXiv:1008.2743v1 [stat.ML, cs.AI, stat.ME], 46 pages, 9 figures, 2010. [5.5 MB]
%
%   * License: Please see the file license.txt included with the code distribution
%              
%
%   * If you use this code in your own work or alter this code, please cite the above paper. This code is distributed "as is" and no
%   guarantee is given as to the accuracy or validity of the results produced by running this code. No responsibility will be assumed
%   of the effects of running this code or using its results in any manner.
%
%   * AUTHOR: GAUTAM V. PENDSE
%     DATE: 2nd April 2010
%=========================================================================

Read input image

    % read input file
    A = imread( imgfile );

    % save a copy of the original image
    A_orig = A;

    % convert to double
    A = double(A);

    % average across rgb
    A = mean(A,3);

Pre-process image

    % get mean intensity in A
    mean_A = mean(A(:));

    % get std of intensity in A
    std_A = std(A(:));

    % make A zero mean and unit standard deviation
    A = ( A - mean_A ) / std_A;

Check results

    % first plot original image
    figure;
    imagesc( A_orig ); % this is rgb image


    % next plot pre-processed image
    figure;
    imagesc( A ); % this is grayscale image
    colorbar;
end