# Image Processing method for spiky selection

I have an input as a 3D binary image and the preferred output below:

Input:

Preferred Output:

What image processing methods should I look for if I am to have only the spiky object(s) remain, just like the preferred output above?

-
What do you mean by 3D binary image? Can you easily segment the image into individual parts? –  bjoernz Mar 3 '12 at 7:11
By 3D, I mean It's a tomographical image. –  Karl Mar 3 '12 at 7:27
Can you explain what is spiky object? What really calls it spiky? what are the key characteristics to spot spiky objects? –  Dipan Mehta Mar 3 '12 at 7:53
A spiky object in this case is a 3D area that is not smooth and has these thorn like shapes all over them. –  Karl Mar 3 '12 at 10:18

There are more corners on the borders of your "spiky object", so one approach would be to tune a corner detector for this.

For example, I calculated the determinant of the structure tensor (Mathematica code below) of a distance-transformed image:

Binarizing with hysteresis yields this image, which should be a good starting point for the segmentation algorithm of your choice:

Mathematica code (src is the source image you posted)

At first, i calculate a distance transform of the input image. This creates contrasts over the whole object area (instead of just the border), so the whole object can be detected.

dist = ImageData[DistanceTransform[src]];


Next I prepare the components of the structure tensor. The filter size for the gaussian derivatives if 5, the window size is 20.

gx = GaussianFilter[dist, 5, {1, 0}];
gy = GaussianFilter[dist, 5, {0, 1}];
gx2 = GaussianFilter[gx^2, 20];
gxy = GaussianFilter[gx*gy, 20];
gy2 = GaussianFilter[gy^2, 20];


To calculate the corner filter at each pixel, I simply plug these into the symbolic determinant of the structure tensor:

corners = Det[{{dx2, dxy}, {dxy, dy2}}] /. {dx2 -> gx2, dxy -> gxy, dy2 -> gy2};


Which is basically the same as:

corners = gx2 * gy2 - gxy * gxy;


Converting this to an image and scaling it to 0..1 range yields the corner detector image above.

Finally, binarizing it with the right thresholds gives the final, binary image:

MorphologicalBinarize[Image[corners], {0.025, 0.1}]

-
Very cool answer! = ) –  Phonon Mar 4 '12 at 1:54
Your answers are amazing, I learn a lot from them. –  Andrey Oct 11 '12 at 11:40