필터 지우기
필터 지우기

How to count grain in which the image is eroded?

조회 수: 2 (최근 30일)
Jothika Charlees
Jothika Charlees 2017년 1월 20일
댓글: Walter Roberson 2017년 1월 20일
Hi, I'm a student and doing a project in image processing. I have to label and count this image .

채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 20일
Unless you expect the count to be something other than 12, you can use bwlabel()
  댓글 수: 4
Jothika Charlees
Jothika Charlees 2017년 1월 20일
편집: Walter Roberson 2017년 1월 20일
clc;
clear all;
close all;
a=imread('grain 2.jpg');
figure
imshow(a);
title('Input image');
b=rgb2gray(a);
figure
imshow(b);
title('Grayscale image');
c=medfilt2(b,[3 3]);
figure
imshow(c);
title('Median filtered image');
d = im2bw(b,0.5);
figure
imshow(d);
title('Binarized image');
se = strel('disk',11);
e = imerode(d,se);
figure
imshow(e);
title('Eroded image');
[labeledImage, numberOfBlobs] = bwlabel(e, 8);
coloredLabelsImage = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
figure;
imshow(coloredLabelsImage);
title('Labeled Image');
this is the code i used but i don't know how to label the image grain with numbers. The attachment shows the output image that i get using this code
Walter Roberson
Walter Roberson 2017년 1월 20일
Yes, that is a labeled image in MATLAB terms. Each different area has been given a different number, and each different number has been represented as a different color based upon the current colormap() .
Perhaps what you wanted was some text written onto each blob. If so then use regionprops() to request the Centroid . Loop through the returned information, pull out the Centroid information, and text() the appropriate label number at that location.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by