Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

how to count big cell only?

Asked by Moon Shadow

Moon Shadow

on 10 Mar 2014
Latest activity Answered by Image Analyst

Image Analyst

on 25 Mar 2014

I have image with different cell size but I want Count the number of big cells only!!

I try this code:

A = imread ('cell.png');
level=graythresh(A);
I=im2bw(A,level);
[labeled,numObjects]=bwlabel(I,4)
numObjects = 26

0 Comments

Moon Shadow

Moon Shadow

Products

No products are associated with this question.

2 Answers

Answer by Dishant Arora

Dishant Arora

on 10 Mar 2014
Edited by Dishant Arora

Dishant Arora

on 10 Mar 2014
Accepted answer

use bwareaopen to remove objects smaller than certain number of pixels.

 BW2 = bwareaopen(BW, thresh);
[~, numObjects] = bwlabel(BW2,4);

2 Comments

Moon Shadow

Moon Shadow

on 21 Mar 2014

It did nit worked with me!!

It calculate small and big cells.

I = imread('cell.png'); EDU>> imshow(I); EDU>> bw = im2bw(I); EDU>> figure,imshow(bw);

EDU>> BW2 = bwareaopen(bw, 1000); EDU>> figure,imshow(BW2); [labeled,numObjects]=bwlabel(BW2,4) numObjects = 10

Dishant Arora

Dishant Arora

on 25 Mar 2014

Check out for 8-connectivity when using bwlabel or attach your image.

Dishant Arora

Dishant Arora

Answer by Image Analyst

Image Analyst

on 25 Mar 2014

See my code to extract the largest blob, attached below in blue. In there, there is a general purpose function I wrote that can take the N largest or smallest blobs in a binary image.

0 Comments

Image Analyst

Image Analyst

Contact us