clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 14;
Nx=64;
Ny=Nx;
eta2 = zeros(64,64);
load storeEtas
for igrain=1:25
ncount=0;
for i=1:Nx
for j=1:Nx
ii =(i-1)*Nx+j;
eta2(i,j) =eta2(i,j)+etas(ii,igrain)^2;
if(etas(ii,igrain) >= 0.5)
ncount=ncount+1;
end
ncount=ncount/(Nx*Ny);
end
end
end
figure
subplot(2, 3, 1);
imshow(eta2, [], 'ColorMap', hsv(256));
colorbar;
title('eta2, Pseudo-colored', 'FontSize', fontSize);
impixelinfo;
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
drawnow;
subplot(2, 3, 2);
imshow(eta2, [], 'ColorMap', gray(256));
colorbar;
title('eta2, Actual values (gray scale)', 'FontSize', fontSize);
impixelinfo;
subplot(2, 3, [3, 6]);
imhist(eta2);
grid on;
title('Histogram of eta2', 'FontSize', fontSize);
thresholdValue = 0.7;
line([thresholdValue, thresholdValue], ylim, 'Color', 'r', 'LineWidth', 2);
binaryImage = eta2 > thresholdValue;
subplot(2, 3, 4);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
[labeledImage, numberOfBlobs] = bwlabel(binaryImage, 8);
fprintf('Found %d blobs.\n', numberOfBlobs);
coloredLabelsImage = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
subplot(2, 3, 5);
imshow(coloredLabelsImage);
title('Individually colored regions of eta2', 'FontSize', fontSize);
blobMeasurements = regionprops(labeledImage, eta2, 'all')
allAreas = [blobMeasurements.Area]
Best Answer