Created
July 7, 2015 21:57
-
-
Save hmparanjape/9646f210b32d4e6b97e8 to your computer and use it in GitHub Desktop.
Visualize 2D strain obtained using NCORR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 2D DIC strain analysis | |
% | |
% 1. Run handles_ncorr = ncorr | |
% 2. Save the data and load the MAT file | |
% 3. Run this | |
% | |
num_of_dic_images = numel(current_save); | |
% | |
% exx = 2D distribution of xx strain component in the ROI | |
exx = cell(num_of_dic_images,1); | |
% Save strain from each DIC result | |
for i = 1:num_of_dic_images | |
exx{i} = data_dic_save.strains(i).plot_exx_cur_formatted; | |
end | |
% Calculate mean and std deviation for each frame | |
% Calculate for exx now | |
exx_avg = zeros(num_of_dic_images,1); | |
exx_std = zeros(num_of_dic_images,1); | |
for i = 1:num_of_dic_images | |
exx_temp = exx{i}; | |
exx_avg(i) = mean(exx_temp(exx_temp ~= 0)); | |
exx_std(i) = std(exx_temp(exx_temp ~= 0)); | |
end | |
% Plot avg strain and errorbars | |
plot(exx_avg) | |
errorbar(exx_avg, exx_std) | |
xlabel('DIC frame') | |
ylabel('Strain (xx)') | |
%ylim([0 3e-3]) | |
% | |
% Save an image sequence from 2d strain plots | |
make_image_sequence = 1; | |
strain_limits = [-0.06 0]; | |
plot_save_dir = '/Volumes/Secondary HD/Work/Deformation_in_Fe_Pd_Single_Crystals/FePd_d_DIC/exx_2d_plots'; | |
if(make_image_sequence) | |
for i = 1:num_of_dic_images | |
% Get bounding box for the first frame. We will crop all the images | |
% to that bbox | |
if(i == 1) | |
exx_temp = exx{i}; | |
exx_temp = abs(floor(exx_temp/max(abs(exx_temp(:)))*256)); | |
exx_temp = uint8(exx_temp); | |
% Get bounding box | |
exx_bbox = regionprops(exx_temp ~= 0, 'BoundingBox'); | |
exx_bbox = exx_bbox.BoundingBox; | |
% We dilate the bbox by 20% so that the deformed configuration | |
% fits in it as well. | |
exx_bbox(1) = floor(exx_bbox(1) - 0.1*exx_bbox(3)); | |
exx_bbox(2) = floor(exx_bbox(2) - 0.1*exx_bbox(4)); | |
exx_bbox(3) = floor(exx_bbox(3) + 0.2*exx_bbox(3)); | |
exx_bbox(4) = floor(exx_bbox(4) + 0.2*exx_bbox(4)); | |
end | |
% Plotting | |
exx_temp = exx{i}; | |
h = figure; | |
pcolor(exx_temp(exx_bbox(2):(exx_bbox(2) + exx_bbox(4)), ... | |
exx_bbox(1):(exx_bbox(1) + exx_bbox(3)))); | |
shading flat; | |
axis off; | |
colorbar; | |
set(gca, 'FontSize', 16) | |
caxis([strain_limits(1) strain_limits(2)]); | |
title(['Strain, average = ' num2str(exx_avg(i)) ', stdev = ' num2str(exx_std(i))]); | |
print(h, '-dpng', fullfile(plot_save_dir, ['strain_2d_' sprintf('%04d', i)])); | |
close(h); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment