Count Grain Number from Input Image

5 次查看(过去 30 天)
Parth Desai
Parth Desai 2018-9-10
回答: AMAR P 2018-10-10
Hello,
How can I calculate number of grains from metal image ? Based on grain number I want to find out input image is of which metal. Should I use line and point-sampled intercept length methods for finding number of grains.

回答(1 个)

AMAR P
AMAR P 2018-10-10
hi I hope you have worked out the problem. Here is my take on a problem. Might help others in coming years.
% file:
% Author: AMAR P.
% Version: V1
clc
clearvars;
close all;
MainImg = imread('Temp.bmp');
% Convert to GrayScale Image [To perform histeq]
GrayImg = rgb2gray(MainImg);
% Intensity transformation
GrayImg = histeq(GrayImg);
% Convert to Binary Image
BinImg = im2bw(GrayImg);
%Get Resion props
GrainProps = regionprops('table', BinImg,'Centroid');
% Get No of Grains in the image
NoOfGrains = numel(GrainProps);
%Read All Centers into Array
GrainCenters = GrainProps.Centroid;
% Mark Grains at Center.
figure(1);
imshow(BinImg);
hold on;
text(GrainCenters(:,1), GrainCenters(:,2),'*','Color','r');
hold off
fprintf('\nNo. Of Grains found in the Image = %d\n', NoOfGrains);
_ No. Of Grains found in the Image = 610_

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

产品


版本

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by