## How to calculate solidity of different shapes

on 19 Sep 2013

### Image Analyst (view profile)

I have an image which contains different shapes:

I want to calculate the solidity of each shape individually and pick the one which has greatest solidity;

Can any one help me regarding this?

### Image Analyst (view profile)

on 19 Sep 2013
Edited by Image Analyst

### Image Analyst (view profile)

on 19 Sep 2013

Did you use regionprops() to get all of them? If so, then just sort

```% Label the binary image.
labeledImage = bwlabel(binaryImage);
% Measure the solidity of all the blobs.
measurements = regionprops(labeledImage, 'Solidity');
% Sort in oder of decreasing solidity.
[sortedS, sortIndexes] = sort([measurements.Solidity], 'descend');
% Get the solidity of the most solid blob
highestSolidity = sortedS(1);
% Get the label of the most solid blob
labelWithHighestSolidity = sortIndexes(1);
```

naila

### naila (view profile)

on 19 Sep 2013

Thank you so much for your time Sir!

### Image Analyst (view profile)

on 20 Sep 2013
Edited by Image Analyst

### Image Analyst (view profile)

on 20 Sep 2013

naila: See attached file and see if it does what you want.

naila

### naila (view profile)

on 22 Sep 2013

Thank You very much Sir... This is all what I need...; Thanks for your time;

### naila (view profile)

on 19 Sep 2013

I get an error related to bigS();

MATLAB says 'undefine command /function bigS';

what should I do now. I Google for bigS() but not succeed;

Image Analyst

### Image Analyst (view profile)

on 19 Sep 2013

It should be sortedS, not bigS. My mistake - I'll correct it.

### naila (view profile)

on 19 Sep 2013

Plz Sir I want to get the solidity of squared region at the image. But your code generates Fig having just one white pixel at the centre;

help plz

Image Analyst

### Image Analyst (view profile)

on 19 Sep 2013

Do you have some way of getting the binary image of the blobs in the red rectangle? If so, post it, otherwise post the binary image itself.

### naila (view profile)

on 20 Sep 2013

This is the full Image Sir; I want to calculate solidity of all the blobs in the image and then pick up just that one which has higher solidity; and show just that blob, not the full image;

Thank you so much for your time;

### naila (view profile)

on 20 Sep 2013

This is the full Image Sir; I want to calculate solidity of all the blobs in the image and then pick up just that one which has higher solidity; and show just that blob, not the full image;

Thank you so much for your time;

on 20 Sep 2013

on 20 Sep 2013

Image Analyst

### Image Analyst (view profile)

on 20 Sep 2013

Didn't my answer already do that? I presume you know how to call imread() - what else do you need?

naila

### naila (view profile)

on 20 Sep 2013

Sir when I run the code, and show the image by imshow() it give me a fig just having one white pixel at the mid of the fig; I need the full largest blob

Image Analyst

### Image Analyst (view profile)

on 20 Sep 2013

A single pixel will have maximum solidity - think about it. The largest blob will not necessarily have the highest solidity. What if the largest blob is a huge C shape? So do you want largest area? Highest Solidity? Or highest solidity for blobs bigger than a certain area? You need to define your criteria before you or I can write a program for it.