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



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?

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

1 Answer 1


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:

enter image description here

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

enter image description here

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}]
  • $\begingroup$ Very cool answer! = ) $\endgroup$
    – Phonon
    Commented Mar 4, 2012 at 1:54
  • $\begingroup$ Your answers are amazing, I learn a lot from them. $\endgroup$ Commented Oct 11, 2012 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.