remove non-circle objects from image

It looks that I tried everything (eccentricity, bwareaopen and so on)but nothing works. Maybe someone could suggest a way to do it?
I am dealing with this image (two styles of representation):
shapes=[stats.Eccentricity];
removeA2=bwareaopen(shapes<0.20,100);
or
bw = bwareaopen(bw, 50);
and others. I just can't find it in my code. I think =edge(); didn't worked well enough.

8 件のコメント

Sean de Wolski
Sean de Wolski 2011 年 10 月 26 日
Well first off, you did not try _everything_. What have you tried? Show us, in code, and give us a link to an image that you have so we can see what you're working with.
Also, be sure to check out ImageAnalyst's "blobsdemo" on the fex.
Sean de Wolski
Sean de Wolski 2011 年 10 月 26 日
What about 'extent' or perimeter to area ratios? These are all easy options in regionprops.
LG9
LG9 2011 年 10 月 26 日
I tried to read about it but I couldn't do it by myself
LG9
LG9 2011 年 10 月 26 日
I found those ratios but I don't know how to use them to remove objects
Sean de Wolski
Sean de Wolski 2011 年 10 月 26 日
Well how are you going to learn to solve problems without working through them yourself? Take a look at the 'extent' of a few of the blobs, see if you notice a pattern. Or look at the area to perimeter ratio, and once again look for a pattern.
LG9
LG9 2011 年 10 月 26 日
http://postimage.org/image/yruinlal7/
Sean de Wolski
Sean de Wolski 2011 年 10 月 26 日
Good job! There's a pretty obvious pattern there, threshold those values and keep the high ones.
LG9
LG9 2011 年 10 月 26 日
so I am trying to set threshold value and then use bwareaopen(). Where is my mistake?
threshold = 0.8;
F = bwareaopen(fillA,threshold);
imshow(F)

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

回答 (1 件)

Sven
Sven 2011 年 10 月 28 日

2 投票

% Get the image as a b&w indexed (non-rgb) image
I = imread('project.jpg');
BW = rgb2ind(I, 2);
% Calculate its connected regions
L = labelmatrix(BW); % Not using bwconncomps() for older version users
stats = regionprops(CC,'Extent','Area');
% Find the ones that are like a circle
minExtent = 0.75;
keepMask = [stats.Extent]>minExtent;
% Extract the image of circles only and display
BWcircles = ismember(L, find(keepMask));
BWnonCircles = BW & ~BWcircles;
% Show the circles
figure, imshow(BWcircles)
% Show the things we removed
figure, imshow(BWnonCircles)
% Show them together in different colours
RGB = double(cat(3, zeros(size(BW)), BWcircles, BWnonCircles));
figure, imshow(RGB)

6 件のコメント

LG9
LG9 2011 年 10 月 31 日
Could function below be available only on the newest version of program? It looks that it is not recognised by a Matlab which is in my university
CC = bwconncomp(BW);
Sean de Wolski
Sean de Wolski 2011 年 10 月 31 日
What version are you using? Type >> ver at the command line.
Sven
Sven 2011 年 11 月 1 日
You may have a version before bwconncomp()
It can equivalently be:
BW = rgb2ind(I, 2);
L = bwlabel(BW);
stats = regionprops(L, ...)
LG9
LG9 2011 年 11 月 2 日
thanks, now it works on the version I have but this code identifies circle objects. I think I was able to do this before. I just don't know how to remove other objects who has coefficient <0.7 for example
Sven
Sven 2011 年 11 月 2 日
LG9, I chose to show you all circles (stored in BWcircles) and all non-circles (stored in BWnonCircles), just in different colours. If you want to "remove non-circles", then all you have to do is look at the BWcircles image by itself:
figure, imshow(BWcircles)
Sven
Sven 2011 年 11 月 4 日
LG9, if your question has been answered, hit "accept" to remove it from the "unanswered" list.

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

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

タグ

質問済み:

LG9
2011 年 10 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by