Open In App

MRI Image Segmentation in MATLAB

In the domain of digital image processing, sometimes we need to separate the main object from the image for clear observation. Image segmentation is the process that enables this partitioning. In this method, each pixel is assigned a label, and pixels that share some characteristics are assigned the same label number. This technique is widely used in the medical domain to locate the object of interest.

It is a technique to partition a digital image into multiple segments. This process is widely used in medical diagnosis. Here in this article, we have used morphological operations to segment the brain part from the MRI image. The segmentation is carried out in order to facilitate the analysis of the segmented images. 



What is Medical imaging?

This term refers to the technique which medical professionals use to view inside the human body in order to diagnose, monitor, and treat. There are various techniques available in the modern scientific age.

Types of Image Segmentations:

There exist many types of image segmentation. 



In this article, we are working on separating the brain part of the MRI image. 

Morphological operations used: 

Function Used:

Steps:

Example:




% MATLAB code for
% Separate the brain part from MRI image.
 
% read the mri image.
k=imread("mrii.jpg");
 
% display the image.
imtool(k,[]);
 
% convert it into binary image.
k1=im2bw(k,graythresh(k));
 
% display the binary image.
imtool(k1);
 
% Make the brain largest connected component.
% We need to apply opening operation.
% define the structuring element.
SE=strel('disk',7,4);
 
% apply the opening operation.
k2=imopen(k1,SE);
 
% display the image now.
imtool(k2);
 
% apply connected component analysis.
b=bwlabel(k2);
 
% display the colored map image.
imtool(b,[]);
 
% brain is component labeled as 9.
% set all other component as 0 except brain.
b(b~=9)=0;
 
% display the brain part.
imtool(b);
 
% inside the brain part, black portion is there.
% close the black pixels inside brain part.
k3=imclose(b,strel('disk',18));
 
% display the brain part.
imtool(k3);
 
% extract the brain from original image.
k4=k3.*double(k);
 
% display the real brain from original image.
imtool(k4,[]);

Output:

Figure 1: Original image

Figure 2: Binary image

Figure 3:After applying to open

Figure 4:ColourMap image

Figure 5:Biggest connected component

Figure 6: After applying to close on the brain part

Figure 7:Brain extracted from the original image

Code explanation:

 


Article Tags :