# Detecting the Prescence of a “Tail”

I have a set of objects, which may be spherical or elongated, which may or may not have a tail like structure attached to one or two ends. The tail may be long or short. It may also have a curve to it.

I'm currently looking over the information returned by regionprops and trying to see if anything jumps out at me which could be used to discriminate between normals and tails. I am also playing around with some morphological operations.

An opening operation followed by a comparison to the original mask is my current thought, but I'm not certain that this will be reliable enough in the presence of elongated cells, and I haven't yet found the "perfect" structuring element.

As I am not highly experienced in the IA field (more of an intermediate level), I am thinking that it may be a good idea to reach out and see if others have any ideas that I have not yet considered.

Test images are below. The effective dynamic range is 12-bits, but I've normalized them so that they can be viewed more easily.   And here is a "normal" for comparison: • You could calculate the Hu moments and see how they compare. – D.J.Duff Jun 6 '14 at 6:15

You could check how "circular" a blob is, by computing the ratio between area and the square of perimeter.
For a circle that would be:

$A = \pi r^2 , P = 2 \pi r$,

which implies that

$\frac{A}{P^2} = \frac {1}{4 \pi}$

Probably those who have tail will have different ratio. Both the area and the perimeter of the blob can be calculated in Matlab by using regionprops.

Another option [which could be interesting if you have a lot of data] would be computing many blob properties and training an SVM/Boosting/Other machine learning algorithm.

To distinguish between round shapes and tails, you could simply use statistical tools:

Say you have a density map $P(x, y)$ (which you may approximate simply by your image if you want). The center of mass is:

$(\bar{x}, \bar{y}) = (\int x \cdot P(x,y) dx, \int y \cdot P(x,y) dy )$

(I use the $\int$ symbol for convenience, it generalizes the sum over more complex spaces. In your case, use the sum over pixels.) Similarly, you can compute the covariance matrix :

$C_{xx} = (\int (x - \bar{x})^2 \cdot P(x,y) dx \\ C_{yy} = (\int (y - \bar{y})^2 \cdot P(x,y) dy \\ C_{xy} = (\int (x - \bar{x}) \cdot (y - \bar{y}) \cdot P(x,y) dx$

This would give the shape that best approximates your object with the hypothesis it is round (that is, fitted by a Gaussian shape $G(x,y)$).

Now, you can examine the deviation of your actual shape $P$ (measure) with the model (gaussian $G$). A natural solution is to use the Kullback-Leibler pseudo-distance:

$D( P || G ) = \int P(x, y) \frac{\ln P(x, y)}{\ln G(x, y)} dx dy$

If qualitatively, you see 2 populations (tailed vs non-tailed), the histogram of these distances should be quantitatively bimodal.

The only information you need about each shape is the outer edge, using edge detection. A good edge detection for the outer edge can be to start in a black zone distant to the centre of mass and iterate towards and around the form. Once you have the edge, you only need to measure the angle in between points on the edge in segments, and measure the regularity of the edge of the shape. If there is a large deviation from the regular circular tendency which extends the edge away from the center on a central axis leading towards the center, then it is a tail. You can measure the same algorithm clockwise and counter clockwise.