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

  • img1
  • img2

Some codes:

Img= imread('sub.png');
Img = adapthisteq(Img);
figure, imshow(Img), title('After Adjustment Image')
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(Img), hy, 'replicate');
Ix = imfilter(double(Img), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure, imshow(gradmag,[]), title('gradmag')
%threshold = graythresh(im);
originalImage = im2bw(Img,.18);
figure, imshow(originalImage), title('After thresholding')
originalImage = bwareaopen(originalImage,150);
figure, imshow(originalImage), title('After bwarea')
for i=1:k
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(im), hy, 'replicate');
Ix = imfilter(double(im), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure, imshow(gradmag,[]), title('gradmag')

se = strel('disk', 1); %# structuring element
closeBW = imclose(gradmag,se);
CC = bwconncomp(closeBW);
L = labelmatrix(CC);
[labeled,numObjects]= bwlabel(im);
figure, imshow(label2rgb(L));
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);



source to share

1 answer

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.



All Articles