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_process_results.m
% Code to visualize DIC raw thermal expansion results files
% Programmed by Rob
% Last revision: 4/16/2007


clear all;
clc;


% Remove bad correlation points

remove_bp_selection = menu(sprintf('Would you like to remove (or continue removing) points that correlated incorrectly or has this already been completed?'),'Remove Badpoints','Skip');

if remove_bp_selection == 1;

    RJT_remove_badpoints;
end;




% Close open figure; plot and save an image of the final raw correlation results

close(gcf);

plot_bp_selection = menu(sprintf('Would you like to save the badpoint removal results as a figure and image?  This may take a few moments...please be patient.'),'Save Results','Skip');

if plot_bp_selection == 1;

    load validx.txt;
    load validy.txt;
    load filenamelist;
    [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

    W = figure;
    hold on;
    set(W,'Position',[150,50,800,600]); % [left bottom width height]
    set(W,'PaperPositionMode','auto');
    image(imread(filenamelist(1,:)));
    axis image;
    xlabel('x-Location on Image [Pixels]');
    ylabel('y-Location on Image [Pixels]');
    title(['Number of Correlation Points: ',num2str(num_points)]);
    plot(validx_vector,validy_vector,'.r');
    box on;

    saveas(W,'badpoints_removed_results.fig');
    print -djpeg -r300 badpoints_removed_results;
end;




% Find the temperature for each image by matching the commensurate time data

match_selection = menu(sprintf('Would you like to match temperature-image data or has this already been completed?'),'Match Data','Skip');

if match_selection == 1;

    RJT_match_data;
end;




% Compute the displacement field

disp_selection = menu(sprintf('Would you like to calculate the displacement field or has this already been completed?'),'Compute Displacement','Skip');

if disp_selection == 1;

    RJT_displacement_2D;
end;




% Compute the strain field

strain_selection = menu(sprintf('Would you like to calculate the thermal strain data or has this already been completed?'),'Compute Strain','Skip');

if strain_selection == 1;

    RJT_strain_1D;
end;




% Compute either the strain resolution results or the temperature-dependent cte results

big_selection = menu(sprintf('Would you like to calculate strain resolution or CTE results?'),'Compute Strain Resolution','Compute CTE');




% Compute the strain resolution results

if big_selection == 1;

    % Load the raw strain data; close any open figures from prior analysis

    close(gcf); close(gcf);

    load raw_strain_temperature.txt;
    load filenamelist;

    % Prompt user for images to be used for the strain resolution analysis

    prompt = {'Enter the number of the first image (i.e. "3" for PIC10003) that was taken at fixed temperature:','Enter the number of the last image (i.e. "100" for PIC10100) that was taken at fixed temperature:'};
    dlg_title = 'Input constant temperature image range';
    num_lines = 1;
    def = {'1','100'};
    answer = inputdlg(prompt,dlg_title,num_lines,def);
    start_num = str2num(cell2mat(answer(1,1)));
    stop_num = str2num(cell2mat(answer(2,1)));

    offset = start_num-str2num(filenamelist(1,(5:8)))+1;

    image_num = 1:(stop_num-start_num+1);
    epsxx_res = raw_strain_temperature((offset:(stop_num-start_num+offset)),2)-mean(raw_strain_temperature((offset:(stop_num-start_num+offset)),2));

    % Plot and save the strain resolution results

    X = figure;
    AH = axes('fontsize',18,'fontweight','bold');
    hold on;
    set(X,'Position',[150,50,800,600]); % [left bottom width height]
    plot(image_num,epsxx_res*1e4,'og','linewidth',2,'markersize',6);
    plot(image_num,epsxx_res*1e4,'k','linewidth',1);
    xlabel('Image Number');
    ylabel('Strain Resolution [\mu\epsilon]');
    box on;

    strain_res_image_data = [image_num' epsxx_res];
    save strain_resolution_image.txt strain_res_image_data -ascii -tabs;
    saveas(X,'strain_resolution_image.fig');
    print -dtiff -r300 strain_resolution_image;
end;




% Compute the temperature-dependent cte results

if big_selection == 2;

    % Load the raw strain data; close any open figures from prior analysis

    close(gcf); close(gcf);

    load raw_strain_temperature.txt;
    cte_temps_raw = raw_strain_temperature(:,1);
    epsxx_raw = raw_strain_temperature(:,2);

    % Perform a user-selected polynomial fit of the raw strain data

    prompt = {'Enter the order of the polynomial (1-linear, 2-quadratic, 3-cubic...) to be used to fit the raw strain data:'};
    dlg_title = 'Input fit order';
    num_lines = 1;
    def = {'2'};
    answer = inputdlg(prompt,dlg_title,num_lines,def);
    fit_order = str2num(cell2mat(answer(1,1)));

    warning off MATLAB:polyfit:RepeatedPointsOrRescale;
    poly_coeffs = polyfit(cte_temps_raw,epsxx_raw,fit_order);
    strain_data_fit = polyval(poly_coeffs,cte_temps_raw);

    % Plot and save the raw strain fitting results

    X = figure;
    AH = axes('fontsize',18,'fontweight','bold');
    hold on;
    set(X,'Position',[150,50,800,600]); % [left bottom width height]
    plot(cte_temps_raw,epsxx_raw,'og','linewidth',2,'markersize',6);
    plot(cte_temps_raw,strain_data_fit,'k','linewidth',1);
    xlabel('Temperature [\circC]');
    ylabel('Thermal Strain [%]');
    title(['Fit Order: ',num2str(fit_order)]);
    legend('Raw Strain Data','Polynomial Fit',2);
    box on;

    strain_temperature_data = [cte_temps_raw epsxx_raw strain_data_fit];
    save strain_temperature.txt strain_temperature_data -ascii -tabs;
    saveas(X,'raw_strain_temperature_fit.fig');
    print -dtiff -r300 raw_strain_temperature_fit;

    % Evaluate the residuals (check the fit) and plot and save the results

    fit_residuals = epsxx_raw-strain_data_fit;

    Y = figure;
    AH = axes('fontsize',18,'fontweight','bold');
    hold on;
    set(Y,'Position',[150,50,800,600]); % [left bottom width height]
    plot(cte_temps_raw,fit_residuals,'og','linewidth',2,'markersize',6);
    plot(cte_temps_raw,fit_residuals,'k','linewidth',1);
    xlabel('Temperature [\circC]');
    ylabel('Strain Fit Residuals [%]');
    box on;

    residual_temperature_data = [cte_temps_raw fit_residuals];
    save residual_temperature.txt residual_temperature_data -ascii -tabs;
    saveas(Y,'residual_temperature.fig');
    print -dtiff -r300 residual_temperature;

    % Take an analytical derivative of the fitted strain data to get the cte

    poly_derivative_coeffs = polyder(poly_coeffs); % polyder always just takes 1 derivative
    cte_data = polyval(poly_derivative_coeffs,cte_temps_raw);

    % Plot and save the final cte results

    Z = figure;
    AH = axes('fontsize',18,'fontweight','bold');
    hold on;
    set(Z,'Position',[150,50,800,600]); % [left bottom width height]
    plot(cte_temps_raw,cte_data*1e4,'k','linewidth',2);
    xlabel('Temperature [\circC]');
    ylabel('CTE [ppm/\circC]');
    box on;

    cte_temperature_data = [cte_temps_raw (cte_data*1e4)];
    save cte_temperature.txt cte_temperature_data -ascii -tabs;
    saveas(Z,'cte_temperature.fig');
    print -dtiff -r300 cte_temperature;
end;




% Alert the user that the end of the program has been reached

end_selection = menu(sprintf('Congratulations, you''ve reached the end of the HighCorr CTE program!!!\n\n  All data and figures have been saved so it is now safe to exit Matlab.\n  If some processing steps need to be done over, the program can also be restarted.'),'Exit','Restart');

if end_selection == 1;

    exit;
end;

if end_selection == 2;

    RJT_master;
end;

Contact us at files@mathworks.com