Plot histogram of a series of images and extract cracks
Dear all,
I’m trying to plot histogram of a series of tomography images to assess the threshold for extracting cracks. I don’t understand why the histogram is not displayed. I would like to select at least the first and the last images to determine the threshold. Here is the code:
Thanks a lot for any help
clear all
close all
clc
a= load(‘tomo_carota_8bit.mat’)
x=a.x_8;
x=double(x);
% clear a
%%
figure,
for ii = 1:size(x, 3)
ii
I = squeeze(x(:,:,ii));
imshow(I, []);
pause(0.1)
end
subplot(3,2,1);
imshow(I,[]);
title(‘Original Grayscale Image’, ‘FontSize’, 15);
subplot(3,2,2);
imhist(I);
title(‘Histogram of original image’);
subplot(3,2,3);
imhist(I);
[counts, grayLevels] = imhist(I);
bar(grayLevels, counts, ‘EdgeColor’, ‘r’, ‘FaceColor’, ‘b’, ‘BarWidth’, 1);
xlim([0, max(I(:))]);
%xlim([0 100])
title(‘Histogram of original image zoomed’);
subplot(3,2,4);
thresholdValue = 85;
thresholdValue1 = 60;
f.InvertHardcopy = ‘off’;
binaryImage1 = I > thresholdValue1;
imshow(binaryImage1, []);
title(‘Binary Image threshold 85’);
f.InvertHardcopy = ‘off’;
binaryImage = I > thresholdValue;
subplot(3,2,5);
imshow(binaryImage, []);
title(‘Binary Image threshold 60’);
figure (1)Dear all,
I’m trying to plot histogram of a series of tomography images to assess the threshold for extracting cracks. I don’t understand why the histogram is not displayed. I would like to select at least the first and the last images to determine the threshold. Here is the code:
Thanks a lot for any help
clear all
close all
clc
a= load(‘tomo_carota_8bit.mat’)
x=a.x_8;
x=double(x);
% clear a
%%
figure,
for ii = 1:size(x, 3)
ii
I = squeeze(x(:,:,ii));
imshow(I, []);
pause(0.1)
end
subplot(3,2,1);
imshow(I,[]);
title(‘Original Grayscale Image’, ‘FontSize’, 15);
subplot(3,2,2);
imhist(I);
title(‘Histogram of original image’);
subplot(3,2,3);
imhist(I);
[counts, grayLevels] = imhist(I);
bar(grayLevels, counts, ‘EdgeColor’, ‘r’, ‘FaceColor’, ‘b’, ‘BarWidth’, 1);
xlim([0, max(I(:))]);
%xlim([0 100])
title(‘Histogram of original image zoomed’);
subplot(3,2,4);
thresholdValue = 85;
thresholdValue1 = 60;
f.InvertHardcopy = ‘off’;
binaryImage1 = I > thresholdValue1;
imshow(binaryImage1, []);
title(‘Binary Image threshold 85’);
f.InvertHardcopy = ‘off’;
binaryImage = I > thresholdValue;
subplot(3,2,5);
imshow(binaryImage, []);
title(‘Binary Image threshold 60’);
figure (1) Dear all,
I’m trying to plot histogram of a series of tomography images to assess the threshold for extracting cracks. I don’t understand why the histogram is not displayed. I would like to select at least the first and the last images to determine the threshold. Here is the code:
Thanks a lot for any help
clear all
close all
clc
a= load(‘tomo_carota_8bit.mat’)
x=a.x_8;
x=double(x);
% clear a
%%
figure,
for ii = 1:size(x, 3)
ii
I = squeeze(x(:,:,ii));
imshow(I, []);
pause(0.1)
end
subplot(3,2,1);
imshow(I,[]);
title(‘Original Grayscale Image’, ‘FontSize’, 15);
subplot(3,2,2);
imhist(I);
title(‘Histogram of original image’);
subplot(3,2,3);
imhist(I);
[counts, grayLevels] = imhist(I);
bar(grayLevels, counts, ‘EdgeColor’, ‘r’, ‘FaceColor’, ‘b’, ‘BarWidth’, 1);
xlim([0, max(I(:))]);
%xlim([0 100])
title(‘Histogram of original image zoomed’);
subplot(3,2,4);
thresholdValue = 85;
thresholdValue1 = 60;
f.InvertHardcopy = ‘off’;
binaryImage1 = I > thresholdValue1;
imshow(binaryImage1, []);
title(‘Binary Image threshold 85’);
f.InvertHardcopy = ‘off’;
binaryImage = I > thresholdValue;
subplot(3,2,5);
imshow(binaryImage, []);
title(‘Binary Image threshold 60’);
figure (1) threshold, imhist, imshow MATLAB Answers — New Questions