11

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

Input:

INPUT

Preferred Output:

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?

Karl
  • 837
  • 1
  • 9
  • 13

1 Answers1

19

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}]
Niki Estner
  • 6,181
  • 1
  • 30
  • 30