Code covered by the BSD License  

Highlights from
Date Odometer class

image thumbnail

Date Odometer class

by

 

12 Apr 2011 (Updated )

Add an odometer-like object to a plot to show the progression of time.

retrieve_odometer_digit_image(value)
function image_data = retrieve_odometer_digit_image(value)
% Finds & reads the image data corresponding to an odometer digit.
%
% image_data = retrieve_odometer_digit_image(value)
%
% Input:
%   value       0 to 9 or string like 'Jan', 'Feb', etc.
%
% Output:
%   image_data  [R X C X 3] image data

% Kevin J. Delaney, BMT Scientific Marine Services
% April 13, 2011

image_data = [];

if ~exist('value', 'var')
    help(mfilename);
    return
end

if isempty(value)
    errordlg('Input "value" is empty.', mfilename);
    return
end

if isnumeric(value)
    value_string = num2str(value);
elseif ischar(value)
    value_string = value;
else
    errordlg('Input "value" is neither char nor numeric.', mfilename);
    return
end

%   The displayed digit.
image_filename = which([value_string, '.png']);

if isempty(image_filename)
    errordlg(['Unable to find image for value "', value_string, '". ', ...
        'Create desired image using "create_odometer_images.m"'], ...
        mfilename);
    return
end

[image_data, image_map] = imread(image_filename);

if isempty(image_data)
    errordlg(['Unable to read image file "', image_filename, '".'], ...
        mfilename);
    return
end

if ~isempty(image_map)
    image_data = ind2rgb(image_data, image_map);
end

Contact us