I have a 2D image as shown here and need to extract the spatial information about the curves in between each cell division. I have been able to analyze the image and output $\;(x,y)\;$ coordinates where the brightest values (1.0) are located in the grid of pixels.

How might I be able to process the image to remove noise (inside the cells) leaving only the lines describing the cell outlines?

enter image description here


2 Answers 2


There are a number of nonlinear filters that are possible. One that might help is the RidgeFilter

ImageAdjust[RidgeFilter[img, 5]]

enter image description here

Let's now clean it up a bit:

Pruning[Thinning[SelectComponents[Binarize[ImageAdjust[RidgeFilter[img, 5]], 0.094], 
        "Count", # > 800 &]]]

enter image description here

The above binarizes the output of the ridge filter. This leaves the desired edges plus some junk in the middle. SelectComponents then removes all the small components, leaving just the desired edges. The result contains the edges but they have become fat; the Thinning function trims them down. The final pruning (as suggested by halirutan) removes a couple of dangling edges.

  • $\begingroup$ Thank you for the assistance. This is exactly the push I needed! $\endgroup$
    – rjd
    Nov 26, 2013 at 14:38

Common functions you should look at are EdgeDetect, Thinning and Pruning. With the already mentioned RidgeFilter this gives

img = Import["http://i.stack.imgur.com/IyUPZ.jpg"];
border = Pruning[Thinning@Closing[EdgeDetect[
  ImageAdjust@RidgeFilter[img, 7], 1], 5], 500];
ColorCombine[{img, img, border}]

Mathematica graphics

  • $\begingroup$ What about doing an initial TotalVariationFiltering with Method->"Poisson"? $\endgroup$
    – UDB
    Nov 20, 2013 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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