# How to eliminate unwanted small areas of the image

I applied the segmentation algorithm to the MRI spine image and then connected the component analysis on the segmented image and got the following image.

This image is composed of unwanted areas. I just need a vertical spine and, more specifically, an intervertebral disc. Can you suggest any method to extract it. Morphological operations will not help. I tried it

• • Some codes:

``````Img= imread('sub.png');
figure,imshow(Img);
Img=rgb2gray(Img);
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(Img), hy, 'replicate');
Ix = imfilter(double(Img), hx, 'replicate');
%threshold = graythresh(im);
originalImage = im2bw(Img,.18);
figure, imshow(originalImage), title('After thresholding')
originalImage = bwareaopen(originalImage,150);
figure, imshow(originalImage), title('After bwarea')
k=2;
tic
for i=1:k
figure
end
toc
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(im), hy, 'replicate');
Ix = imfilter(double(im), hx, 'replicate');

se = strel('disk', 1); %# structuring element
CC = bwconncomp(closeBW);
L = labelmatrix(CC);
[labeled,numObjects]= bwlabel(im);
numObjects
figure, imshow(label2rgb(L));
originalImage=labeled;
se = strel('disk', 1); %# structuring element
originalImage = imclose(originalImage,se);
figure, imshow(originalImage);
stats = regionprops(labeled, 'Area')
%idx = find([stats.Area]>1000 & [stats.Area]<300);
labeled=labeled(labeled<50)
```

```
+3

source to share

Perhaps you could use bivariate correlation. Assuming that the intervertebral discs are horizontally oriented elliptical shapes (in a two-color image), you can try to define an example shape that looks something like what you want to find, and then perform a two-dimensional correlation across the entire field. You will get an image of hopefully brighter points corresponding to the centers of the discs, which you can use as starting points for a more complex process. You may need to do this multiple times using the kernel family.

In addition, although morphological operations do not directly address the problem, there may still be a role for them. For example, if you are defining a structuring element that looks somewhat like your target shape, you can subvert the image with that to try and shrink the linear parts of the image (like the spine) and then do your correlation.

Alternatively, you can try using morphops to close the discs (hard opening and closing) to smooth out all the edges and fill in all the holes. You can then extract the skeleton, prune short branches, and traverse the resulting tree looking at the connectivity of each node: hopefully, if you turned each disk into a solid ellipse between two rails, you can detect them based on that.

0

source

All Articles