count the number of objects in the eight.tif.

조회 수: 20 (최근 30일)
Moon Shadow
Moon Shadow 2014년 2월 11일
댓글: Arturo Jr. Ongkeko 2021년 4월 7일
Can any one help me to count the number of objects in the eight.tif.
I tried this code but it did not work!!
B=imread('eight.tif');
BWl=im2bw(B);
imshow(BWl);
eul=bweuler(BWl,8);
EDU>> eul=
eul=
|
Error: Expression or statement is incomplete or incorrect.

채택된 답변

Sabarinathan Vadivelu
Sabarinathan Vadivelu 2014년 2월 11일
Check this out
I = imread('eight.tif');
imshow(I)
level = graythresh(I);
BW = im2bw(I,level);
imshow(BW)
CC = bwconncomp(~BW);
CC.NumObjects
  댓글 수: 3
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2014년 2월 11일
If this fulfills your needs, then please accept the answer.
Arturo Jr. Ongkeko
Arturo Jr. Ongkeko 2021년 4월 7일
When I run your code, the number of objects it indicated is 6. But the eight.tif has 4 coins right, so we are to expect the count to be 4?
I tried another approach using bweuler but it also counted 6 (see below). I guess I just want to understand the rationale as to why are we getting 6 instead of 4.
Thanks,
Art
% read image and display
img=imread('eight.tif');
imshow(img)
%transform to bw and display
img_bw=im2bw(img,0.6);
figure,imshow(img_bw)
%inverse of the bw/binary
img_complement=imcomplement(img_bw);
%filled the holes in the coins
img_filled=imfill(img_complement,'holes');
%count object using bweuler
bweuler(img_filled)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by