Login  Register

Re: Shape recognition and aspect ratios

Posted by Michael Schmid on Apr 21, 2015; 5:03pm
URL: http://imagej.273.s1.nabble.com/Shape-recognition-and-aspect-ratios-tp5012544p5012556.html

Hi Johanna,

The first steps are not too difficult, but then it becomes tricky.

First you have to convert the image to grayscale and filter it a bit, so you can get at least some reasonable threshold. I suggest edge-preserving blur like the 'Thresholded blur'
  http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:thresholded_blur:start
(Alternatively, if you have Fiji, you could try segmentation by the Trainable Weka Segmentation.)

Then threshold it; select the threshold such that you don't miss many pixels inside the round particles (except 'holes' not connected to the periphery), but without selecting to many particles touching the round ones.

After applying the threshold, get rid of 'holes' in the particles (Process>Binary>Fill Holes) and run Watershed segmentation (Process>Binary>Watershed) to split off at least some extra particles that have merged with the round ones.

The problem is that some round particles still have 'attachments' seemingly protruding from them.
Without that complication, you could run 'Analyze particles', with suitable size range (very small particles are not circular, it seems) and some minimum circularity (e.g. 0.7).
With a macro or in a spreadsheet, can then select particles in the Results, e.g. if 'major' and 'Minor' (from 'Fit Ellipse' in the measurement options) have a suitable ratio, if the perimeter fits what you expect from such an ellipse, whether the min & max Feret diameters fir the minor and major axis, etc. The round particles also have high Roundness and high Solidity (from Set measurements> Shape descriptors).
  http://rsb.info.nih.gov/ij/docs/guide/146-30.html#sub:Set-Measurements...

It is helpful to have 'Analyze Particles' show the 'Overlay Outlines', so you can correlate the particle number with the number in the Results Table.

Another option would be 'Analyze particles' adding particles to the ROI manager, then having a macro to loop over the rois: for each roi, fill it in a separate image, then Edit>Selection>Fit Ellipse and get the statistics for the roi to see how many foreground pixels the particle has in the best-fit ellipse. The more, the closer it comes to an ellipse. Clear the image for the next roi.

Of course, an egg-shaped particle that it is more rounded on one side than on the opposite side (like the big one above the center in the sample image) is not a perfect ellipse. You will need some trial&error to get it right.


Hope it helps at least a bit...

Michael
________________________________________________________________
On Apr 21, 2015, at 06:02, Johanna wrote:

> Hallo,
>
> Is it possible with ImageJ to measure the aspect ratio of only rounds
> features (the maximum radius/the minimum radius) in a picture that also
> contains non round features? I attached a part of that picture.
>
> i am very grateful for any help, as the picture contains some hundrets of
> these round features.
>
> Sample.png <http://imagej.1557.x6.nabble.com/file/n5012544/Sample.png>  
>
>
>
> Thanks a lot,
>
> Johanna

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html