from HighCorr High Temperature Digital Image Correlation Software by Robert Thompson
Software optimized to measure the coefficient of thermal expansion using digital image correlation.

RJT_displacement_2D.m
% Code to calculate the 2D displacement field from the valid correlation points
% Programmed by Rob
% Last revision: 4/5/2007


clear all;
clc;


% Warn user that it could take a while to calculate the displacement field

caution_selection = menu(sprintf('Caution:  After this prompt, Matlab may appear unresponsive for a few seconds while the displacement field is being calculated.\n  Please be patient.  If no results are shown after 30 seconds, then use Control-C to restart the analysis.'),'OK');
close(gcf);

% Load the valid correlation point data, filenamelist, and temperature_image files

load validx.txt;
load validy.txt;
load filenamelist;
load temperature_image.txt;

sizevalidx = size(validx);
sizevalidy = size(validy);
[num_pics num_char] = size(filenamelist);

% Calulate the displacement field vectorially and save the data

validxfirst = validx(:,1)*ones(1,sizevalidx(1,2));
displx = validx-validxfirst;

validyfirst = validy(:,1)*ones(1,sizevalidy(1,2));
disply = validy-validyfirst;

save displx.txt displx -ascii -tabs;
save disply.txt disply -ascii -tabs;

% Plot the displacement field

minmindisplx = min(min(displx));
maxmaxdisplx = max(max(displx));

for i = 1:num_pics;

    plot3(validx(:,i),validy(:,i),displx(:,i),'.r');
    axis([0 3000 0 720 minmindisplx maxmaxdisplx]);
    axis 'auto xy';
    xlabel('x-Location on Image [Pixels]'); % ,'fontsize',18,'fontweight','bold')
    ylabel('y-Location on Image [Pixels]'); % ,'fontsize',18,'fontweight','bold')
    zlabel('x-Component of Displacement [Pixels]'); % ,'fontsize',18,'fontweight','bold')
    grid on;

    title([sprintf('Displacement Field for Image: %10s',filenamelist(i,:)),'      Temperature [\circC]: ',num2str(temperature_image(i,2),'%10.1f')]); % ,'fontsize',18,'fontweight','bold')
    drawnow;

    % Save either a selected group (if num_pics > 10) or all results

    if num_pics <= 10;

        fig_save_string = ['displacement_',num2str(i),'.fig'];
        tiff_save_string = ['displacement_',num2str(i)];

        saveas(gcf,fig_save_string);
        print('-dtiff','-r300',tiff_save_string);

    else;

        v = round(num_pics/3)-1;

        if i == 1;

            saveas(gcf,'displacement_1.fig');
            print -dtiff -r300 displacement_1;
        end;

        if i == v;

            saveas(gcf,'displacement_2.fig');
            print -dtiff -r300 displacement_2;
        end;

        if i == 2*v;

            saveas(gcf,'displacement_3.fig');
            print -dtiff -r300 displacement_3;
        end;

        if i == 3*v;

            saveas(gcf,'displacement_4.fig');
            print -dtiff -r300 displacement_4;
        end;

        if i == num_pics;

            saveas(gcf,'displacement_5.fig');
            print -dtiff -r300 displacement_5;
        end;
    end;
end;




% Ask user if movies of the raw correlation and displacement field results should be created

movieselection = menu(sprintf('Two movies (actually, sets of high resolution images) showing the evolution of the raw correlation and displacement field results from all images can now be created.\n  Depending on the number of images, this may take a while to complete and may also use considerable hard drive space.  Would you like to create these movies?'),'Create Movies','Skip');
close(gcf);

% Create movies if selected

if movieselection == 1;

    % Plot the correlation results (with "hold on") on the current image

    [num_points num_images] = size(validx);

    validx_vector = reshape(validx,num_points*num_images,1); % Convert validx to a one-column vector for plotting
    validy_vector = reshape(validy,num_points*num_images,1); % Convert validy to a one-column vector for plotting

    for i = 1:num_pics;

        W = figure;
        hold on;
        set(W,'Position',[150,50,800,600]); % [left bottom width height]
        set(W,'PaperPositionMode','auto');
        image(imread(filenamelist(i,:)));
        axis image;
        xlabel('x-Location on Image [Pixels]');
        ylabel('y-Location on Image [Pixels]');
        title([sprintf('Correlation Results for Image: %10s',filenamelist(i,:)),'      Temperature [\circC]: ',num2str(temperature_image(i,2),'%10.1f')]); % ,'fontsize',18,'fontweight','bold')
        plot(validx_vector(1:(i*num_points)),validy_vector(1:(i*num_points)),'.r');
        drawnow;
        box on;

        % Save the results from each image

        % fig_save_string = ['movie_corr_results_',num2str(i),'.fig'];
        % tiff_save_string = ['movie_corr_results_',num2str(i)];
        jpeg_save_string = ['movie_corr_results_',num2str(i)];

        % saveas(gcf,fig_save_string);
        % print('-dtiff','-r300',tiff_save_string);
        print('-djpeg','-r300',jpeg_save_string);

        close(gcf);
    end;

    clear W;

    for i = 1:num_pics;

        plot3(validx(:,i),validy(:,i),displx(:,i),'.r');
        axis([0 3000 0 720 minmindisplx maxmaxdisplx]);
        axis 'auto xy';
        xlabel('x-Location on Image [Pixels]'); % ,'fontsize',18,'fontweight','bold')
        ylabel('y-Location on Image [Pixels]'); % ,'fontsize',18,'fontweight','bold')
        zlabel('x-Component of Displacement [Pixels]'); % ,'fontsize',18,'fontweight','bold')
        grid on;
        title([sprintf('Displacement Field for Image: %10s',filenamelist(i,:)),'      Temperature [\circC]: ',num2str(temperature_image(i,2),'%10.1f')]); % ,'fontsize',18,'fontweight','bold')
        drawnow;

        % Save the results from each image

        % fig_save_string = ['movie_disp_results_',num2str(i),'.fig'];
        % tiff_save_string = ['movie_disp_results_',num2str(i)];
        jpeg_save_string = ['movie_disp_results_',num2str(i)];

        % saveas(gcf,fig_save_string);
        % print('-dtiff','-r300',tiff_save_string);
        print('-djpeg','-r300',jpeg_save_string);
    end;
end;

Contact us at files@mathworks.com