フィルターのクリア

I want to find out the region which has a white spot in the image, and how many white spots are available.

5 ビュー (過去 30 日間)
I want to have an output which displays the number of white spots in the image. Also How to define the region of white spot in the image.

回答 (3 件)

Peter Bone
Peter Bone 2014 年 5 月 15 日
You could use regionprops to find the area or bounding box of each region. Look for the region with the right size. That could work on most images. If you need to do it based on shape then you could use Hough transform for circle detection. See the File Exchange.

Image Analyst
Image Analyst 2014 年 5 月 15 日
I'm going to assume that if it's some white area that's not a circle, then you don't want it. So the easiest way, assuming what you show is typical, is to just sum up the white pixels in a rectangular subimages - essentially a template. Let's say you know the starting and ending rows and columns for each rectangular location. Then just do
subimage = binaryImage(row1:row2, col1:col2)
areaFraction = sum(subimage(:)) / numel(subimage);
if areaFraction < someValue
% It's a circle
else
% It's a big mess.
end
If that doesn't work and you need to really go by the shape because you might have other subimages with, say, squares that have the same area fraction, then you need to use regionprops
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'Perimeter', 'EquivDiameter');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
allDiams = [measurements.EquivDiameter];
circularities = appPerimeters.^2 ./ (4*pi*allAreas);
circleIndexes = allDiams > minDiameter & allDiams < maxDiameter & circularities < 2; % Or whatever value works
numberOfCircles = sum(circleIndexes)
Or do it both ways and then resolve conflicts if they disagree.
  1 件のコメント
manpreet singh
manpreet singh 2014 年 5 月 15 日
Yes, I am looking to detect the number of circles in the picture. Thank you for leading me.

サインインしてコメントする。


Julien Moussou
Julien Moussou 2014 年 5 月 15 日
The question is not very specific : what is a white spot ?
If it is just a connex component, see
doc BWboundaries
If it is a somewhat round-shaped form, you need to have some criterion for what is and what is not a white spot, for instance size, ratio of height over length, etc.
  1 件のコメント
manpreet singh
manpreet singh 2014 年 5 月 15 日
Thank you pointing out to me, yes Julien, I want to detect the regions of the White circle in the picture, and I want to obtain a reading of the number of such circles in the picture.
I would appreciate if I can get a code for it.
Regards,

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by