Count Grain Number from Input Image
조회 수: 7 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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_
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!