Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I remember that there was some thread of this sort, but I could not find it, so I hope it's ok to open a new thread.

I want to segment pictures of the brain, i.e. I only want the area within the skull without the bones (all the grey matter/pixels. White parts are bones of the skull).

I have the following two pictures. In the first picture I also want all the grey parts, but you see that there are some white parts intermingled between. So basically the algorithm should segment four different images. In the second pictures it seems to be easier.

Can you guys give me a hint to a function or some examples or threads?

enter image description here

enter image description here

share|improve this question
The second one is super easy. You could do it with just Binarize or your could do something like DeleteSmallComponents@MorphologicalBinarize[img, {0.8, 0.9}]. The first one is another beast because those four segments aren't properly enclosed. – C. E. Jun 12 '14 at 9:55
Try DeleteBorderComponents@ ImageSubtract[i1, Closing[MorphologicalBinarize[i1, {0.9, .99}], 5]] on the first... where i1 is the image. – ciao Jun 12 '14 at 10:00
up vote 4 down vote accepted

Copying the first image into symbol i1:

DeleteBorderComponents@ImageSubtract[i1, Closing[MorphologicalBinarize[i1, {0.9, .99}], 5]]

enter image description here

Second is pretty trivial, see Pickett's comment...

share|improve this answer
ahh MorphologicalBinarize was what I was looking for. Thanks! – holistic Jun 12 '14 at 10:07
@holistic: There's probably a dozen ways to do this, when you have the time, explore the various image-related functions, and play with them - that's how to get a good feel for them... – ciao Jun 12 '14 at 10:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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