MATLAB: Mask Creation on an MRI Image

extractionimageImage Processing Toolboxmaskmriskull stripping

Hello to everyone,
I have an image of the size 128*128, and it is a brain MRI image.
The brain is in the middle of the image and around the brain, there are very small values that I want to set them to zero, so that I can have just the brain area in a black background with surrounding pixels of the value 0, in other words: black. Because I will have to do this with lots of other images too i have to come up with a function.
Therefore I coded an algorithm that extracts a brain mask that I can multiply with the orginal image to just get the brain out. This does work fine, but it's not good enough. So I came up with this new idea that I take a default shape that's similar to the brain structure, and I get it to move around in the orginal image as long as the mean signal in that surface gets a maximum value, this would mean in another words that the shape has aligned itself with the brain, so it will have the maximum mean of signal(or sum of the signals of every pixel).
I can't think of anyway to implement this in code. Can someone help me with this problem? or maybe someone has another better idea to extract a mask from different brain structures similar to my problem.
Thanks alot for any tips.
RF.KS

Best Answer

See my attached skull stripping demo.