How to measure circularity ? What is wrong in this code?
CC=bwconncomp(BW); %BW binary image
labeled=labelmatrix(CC);
stats = regionprops(CC, 'all');
stats.circularity = ((stats.Perimeter) .^2 )./ (4*(pi*(stats.Area)))

1 件のコメント

Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
what are the all possible features I can use to pick the smallest circular-like component ??

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

 採用された回答

Image Analyst
Image Analyst 2014 年 12 月 20 日

0 投票

You didn't use brackets. Try it this way
allPerimeters = [stats.Perimeter];
allAreas = [stats.Area];
allCircularities = allPerimeters .^ 2 ./ (4 * pi* allAreas);

12 件のコメント

Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
I want to pick the smallest circular-like component ... but I have this result
Image Analyst
Image Analyst 2014 年 12 月 21 日
Sort based on the area.
[sortedAreas, sortIndexes] = sort(allAreas);
Then find round indexes
roundBlobs = find(allCIrcularities < someValue);
Then find the first number in sortIndexes that is also in roundBlobs.
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
What are all possible features to detect this blobs?...
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
How can I find the eigenvalues for each component alone??
Image Analyst
Image Analyst 2014 年 12 月 21 日
I have no idea. Maybe you can try this link. Why do you need that?
John D'Errico
John D'Errico 2014 年 12 月 21 日
It is not obvious to me what is meant by circularity on these blobs. Are parts of those snake-like regions, that happen to have a constant curvature, are they circular?
Anyway, circularity is not something that can be accurately determined from eigenvalues. For example, is a square region circular? But if you chose to somehow compute the eigenvalues of a square region, they would be the same. Would that imply a square is circular? Talk about fitting a square peg in a round hole. Suddenly that would be possible! :)
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
編集済み: Nisreen Sulayman 2014 年 12 月 21 日
I want to detect only the cicular-like object(red arrow) in the binary image. What are the suitable features which can be used for this purpose?
How to process each component in the image ?
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
@Image Analyst
Could you please complete the code ....
{
Sort based on the area.
[sortedAreas, sortIndexes] = sort(allAreas); Then find round indexes
roundBlobs = find(allCIrcularities < someValue); Then find the first number in sortIndexes that is also in roundBlobs.
}
I have not really catch the idea.
And please another question....
How can I display all the properties that are given by regionprops for each connected component in the image?
Image Analyst
Image Analyst 2014 年 12 月 21 日
All right. I did it all for you. See attached code, which produces the image below.
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 22 日
編集済み: Nisreen Sulayman 2015 年 6 月 24 日
thank you very much ... thank you
I need to try it on another binary images to detect Blobs(maybe with more shape features) ... I will tell you the results.
Any mail? Thank you again
Image Analyst
Image Analyst 2014 年 12 月 22 日
You're welcome. My email is not necessary.
Hossain Md Shakhawat
Hossain Md Shakhawat 2016 年 11 月 20 日
How can I find the glcm features for the detected blobs.

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

その他の回答 (6 件)

Matt J
Matt J 2014 年 12 月 21 日

0 投票

It might also be useful to check whether the Eccentricity and Solidity of a region are above a certain threshold.

6 件のコメント

Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
How can I display all the properties that are given by regionprops for each connected component in the image?
Matt J
Matt J 2014 年 12 月 21 日
Just display stats(i) to see the properties of the i-th component.
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 21 日
編集済み: Nisreen Sulayman 2014 年 12 月 21 日
I used
STATS = regionprops(L, properties)
to know properties for the connected components in the binary image.... and display the results using stats(i).... BUT how can I know when I write for example stats(1), which is the connected component labeld by "1" in the binary image?? and how to display the image with that component alone??
How can I know properties that belong to the blob(red arrow)?
Matt J
Matt J 2014 年 12 月 21 日
編集済み: Matt J 2014 年 12 月 21 日
Use your label matrix, e.g.,
imagesc(labelled==1)
Image Analyst
Image Analyst 2014 年 12 月 22 日
You can look at my code in my answer where the blobs are labeled with their number in the first figure, and then each blob is cropped out to a separate image with the blob number in the title above the blob.
Nisreen Sulayman
Nisreen Sulayman 2014 年 12 月 22 日
編集済み: Nisreen Sulayman 2014 年 12 月 23 日
thank you very much ... thank you

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

Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 19 日

0 投票

Hi Mr. Image Analyst,
I am working on the code that you have written "test.m", I want to display more properties of the blobs in the image ... 'MajorAxisLength', 'MinorAxisLength', 'Orientation' ... After that I want to copy these values to a doc file
I have modified the code but it didn't work

12 件のコメント

Image Analyst
Image Analyst 2015 年 1 月 19 日
Looks okay. It will write to the command window, not a file. To write to Microsoft Word, you'll have to use ActiveX. Explain in more detail what "didn't work" means to you.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 19 日
it didn't write correctly ?!
Image Analyst
Image Analyst 2015 年 1 月 19 日
Make it easy for me to help you. Post the entire script and image. I'll wait for it.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 19 日
編集済み: Nisreen Sulayman 2015 年 1 月 19 日
I have modified the code "test.m" ....
To display other properties ( 'MajorAxisLength', 'MinorAxisLength', 'Orientation' .)
I have added lines: 124,125,126
modifiy line 152
add line 158
Image Analyst
Image Analyst 2015 年 1 月 19 日
See fixed code, attached. It will find and report the widths of all blobs.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 20 日
編集済み: Nisreen Sulayman 2015 年 1 月 20 日
Thank you Mr. Analyst,
It is ok now. It was not clear to me how to use fprint with that "crazy symbols".
1) Width of the blob means the horizontal axis??
2) How to display values of properties with a field width of tow digits?
3) Can you give me an advice so I learn how to use fprint with symbols?
Image Analyst
Image Analyst 2015 年 1 月 20 日
1. Yes. 2 and 3. In fprintf() and sprintf(), you have format specifiers. When it sees a % symbol, it looks at the numbers and letter after it to decide how to display the variable. f means floating point, d means integer, and s means string. In %T.Lf, L is the number of numbers to the right of the decimal point. and T is the total width of the numbers to the left and right plus the decimal point itself, and any spaced needed to make the whole space for printing be T characters.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 20 日
編集済み: Nisreen Sulayman 2015 年 1 月 20 日
Thank you very much.
How can I get an alert when you "comment" on an answer?
And one last thing please, how to display only the rounded objects in different colors in the original image
Image Analyst
Image Analyst 2015 年 1 月 20 日
You can calculate the circularities and then use ismember to extract them
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = appPerimeters.^2 ./ (4*pi*allAreas);
roundIndexes = find(circularities < 3)
binaryImage = ismember(labeledImage, roundIndexes)>0;
roundMeasurements = regionprops(binaryImage, 'all');
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 21 日
編集済み: Nisreen Sulayman 2015 年 1 月 21 日
May be I haven't asked the question correctly, I want to color the round objects in the gray scale image in "red" or "blue" ... like the following image( I have done this using Paint)
Image Analyst
Image Analyst 2015 年 1 月 21 日
First segment the image to get a binary mask of that thing. Then mask it
red = grayImage;
red(mask) = 255;
green = grayImage;
green(mask) = 0;
blue = grayImage;
blue(mask) = 0;
rgbImage = cat(3, red, green, blue);
imshow(rgbImage);
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 22 日
Thank you very much Mr. Analyst,
I am grateful for your help.

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

Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 19 日

0 投票

I have apllied the code. How can I display the round objects in the original images in different color instead of drawing a circle around them???
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 29 日
編集済み: Nisreen Sulayman 2015 年 1 月 29 日

0 投票

How can I index images according to the resulted segmented image? Is there any thing related to build a database using MATLAB?
Any example or link about this?

7 件のコメント

Image Analyst
Image Analyst 2015 年 1 月 29 日
I don't know what that means. Explain it.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 30 日
編集済み: Nisreen Sulayman 2015 年 1 月 30 日
You can look at the following: https://www.researchgate.net/post/Can_someone_advise_me_about_an_example_of_Content_Based_Image_retrieval
Could you please give me an example how to build database. 3 or 4 images is enough to "database example." And I will increase the size and modify it to meet some requirements.
Image Analyst
Image Analyst 2015 年 1 月 30 日
I don't use the Database Toolbox but you can look into it. Most people here I think just mean a folder of images when they talk about databases. You could analyze them and save the results of them into a mat file if you want. The database should be as big as you need it to be. Maybe 3 or 4 is big enough, but maybe you want more. I don't know what your plans are. Anyway, this sounds like it should be its own question since it's pretty different than your original question. Maybe you'll get more database programmers to answer. I am not a database programmer.
Nisreen Sulayman
Nisreen Sulayman 2015 年 1 月 31 日
Ok,
Regarding segmentation results validation,
1- by visual inspection segmentation algorithm has successfully segmented the region of interest.
2- Results have been also revised\judged by radiologists and they insured the success of algorithm
IS THERE any statistical validation for such kind of results to got accuracy of the algorithm??
Image Analyst
Image Analyst 2015 年 1 月 31 日
Yes, there is. You need to create a Receiver Operating Characteristic, or "ROC Curve". Read more about it in Wikipedia: http://en.wikipedia.org/wiki/Receiver_operating_characteristic
murk hassan memon
murk hassan memon 2018 年 4 月 4 日
stats.circularity = ((stats.Perimeter) .^2 )./ (4*(pi*(stats.Area))) i am getting an error of this sign ^ as such the error is too many input argument.. is there any other method to find the circularity ? if yes? then kindly help me out
Matt J
Matt J 2018 年 4 月 4 日
@murk,
You have multiple objects in "stats" so you need to do something like,
result = ([stats.Perimeter] .^2 )./ (4*(pi*[stats.Area]))

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

Souhardya Roy
Souhardya Roy 2018 年 7 月 6 日

0 投票

The formula is inverse of what is given.

2 件のコメント

yousra zafar
yousra zafar 2019 年 11 月 19 日
can you share the code for finding circular objects . i am also working on aneurysm detection. any guidance from your side will he highly appreciated
Image Analyst
Image Analyst 2019 年 11 月 19 日

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

yousra zafar
yousra zafar 2019 年 11 月 21 日

0 投票

i,m unable to run the code text.m attcahed above, getting error : file not found , can you share with me the image C:\Users\Rose\Documents\Temporary\im.jpg

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by