Effacer les filtres
Effacer les filtres

Count Grain Number from Input Image

6 vues (au cours des 30 derniers jours)
Parth Desai
Parth Desai le 10 Sep 2018
Réponse apportée : AMAR P le 10 Oct 2018
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.

Réponses (1)

AMAR P
AMAR P le 10 Oct 2018
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_

Catégories

En savoir plus sur Import, Export, and Conversion dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by