I want to find out the region which has a white spot in the image, and how many white spots are available.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (3)
Peter Bone
il 15 Mag 2014
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
il 15 Mag 2014
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.
Julien Moussou
il 15 Mag 2014
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.
Vedere anche
Categorie
Scopri di più su Image Segmentation and Analysis in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!