How to remove unconnected pixels or objects from an image
Mostrar comentarios más antiguos
good day all.. i have an image with many unconnected vessels..of pixels i want to remove those pixels how an i do it?

Respuesta aceptada
Más respuestas (1)
Image Analyst
el 5 de Feb. de 2014
2 votos
OK, attached (below in blue text) is code that will get the largest network of vessels.

19 comentarios
vidya
el 5 de Feb. de 2014
vidya
el 6 de Feb. de 2014
Image Analyst
el 6 de Feb. de 2014
May I have your code so I can figure out how your modifications made it not work anymore?
vidya
el 6 de Feb. de 2014
vidya
el 6 de Feb. de 2014
Image Analyst
el 6 de Feb. de 2014
Editada: Image Analyst
el 6 de Feb. de 2014
You already set grayImage to BW2 which is already binary. So grayImage is actually a logical image with values of 0 and 1, not 0-255. So when you then threshold it:
binaryImage = grayImage > 100;
you get a totally black image - not what you want. Just skip the grayImage and binaryImage = grayImage>100 part and most of the other code in that test function - just get rid of those lines. Then put binaryImage in the argument list instead of bw2:
function test(binaryImage)
% Specify how many blobs to extract.
numberToExtract = 1;
%---------------------------------------------------------------------------
% Extract the largest area using our custom function ExtractNLargestBlobs().
% This is the meat of the demo!
biggestBlob = ExtractNLargestBlobs(binaryImage, numberToExtract);
%---------------------------------------------------------------------------
% Display the image.
subplot(2, 2, 4);
imshow(biggestBlob, []);
% Make the number positive again. We don't need it negative for smallest extraction anymore.
numberToExtract = abs(numberToExtract);
caption = sprintf('Extracted Largest Blob');
title(caption, 'FontSize', fontSize);
msgbox('Done with demo!');
Kobi Bilou
el 1 de Jul. de 2016
Hi Image Analyst;
I found that your code is very interesting; I applied your code on a binary retinal image and I found that your code work efficiently when the structures of vessels are all connected (like the previous work)! Else, the code detects only a part of connected vessels (my result)!
It will be very helpful if you have an idea to solve this problem?
PS: A) input image and B) output image (result by your code).
Best
A)

B)

Image Analyst
el 1 de Jul. de 2016
Use bwareafilt(), or else if you use my code (for older versions of MATLAB),
biggestBlob = ExtractNLargestBlobs(binaryImage, numberToExtract);
use some different number for numberToExtract.
Kobi Bilou
el 1 de Jul. de 2016
Thanks for the response dear Image Analyst, it work well when I change the number of numberToExtract. Please, give me the title of the paper of this code, in order to cite it in my work.
Image Analyst
el 2 de Jul. de 2016
bwareafilt() is a Mathworks-written function. You'll have to cite their web page that talks about it. My code, written for an earlier version of MATLAB before they had bwareafilt() just uses other built-in functions like regionprops() and find() and ismember(). Again, you'd have to cite their documentation web pages.
Sidra Aleem
el 16 de Mzo. de 2017
Editada: Sidra Aleem
el 17 de Mzo. de 2017
Respected Sir I am making a project "Personal Identification via retinal blood vessels". I am working on Segmentation. I have implemented segmentation using the following research papers.
I solved some problem using bwareaopen() and bwareafilt(). However it is giving good rest with some images, but not with majority of them. I have attached .m file and output image as well. Please help me. Sir I am new to Matlab and need your help. thanks in advance.
Image Analyst
el 16 de Mzo. de 2017
I'll try, as long as it doesn't require me coding up the entire algorithm from the paper for you. How can I help?
Sidra Aleem
el 16 de Mzo. de 2017
Editada: Sidra Aleem
el 16 de Mzo. de 2017
no no Sir. You do not need to perform the coding of whole paper. At the moment i need to improve segmentation result. I implemented all steps using Matlab documentation. I need help to get good segmentation results with all images. . What I want is to get the blood vessels network, but in the previously sent image the network is not visible. Segmentation with that image did not yield good result. You can see below the one image with which i am getting good result. Please help me to achieve the same with rest. So I can view the network and later extract features.
Thank you

Image Analyst
el 16 de Mzo. de 2017
Was that the algorithm that was in the paper? It seems pretty short? If it doesn't work then I guess it's not a good algorithm and you'll have to adjust it. I can't do much since you forgot to attach the original image that it doesn't work on.
Sidra Aleem
el 17 de Mzo. de 2017
Yes Sir this is the algorithm in the paper. However I added adaptive histogram equalization, Gaussian filtering, Top hat transform. I am trying to attach input image , but I am getting error that you are limited to 10 daily uploads. How can I give you input image?? I did not do 10 uploads.
Image Analyst
el 17 de Mzo. de 2017
Try posting a brand new question ( not here) after clearing your browser cache.
Sidra Aleem
el 17 de Mzo. de 2017
Ok than k you
Quoc Anh Vu
el 29 de Nov. de 2022
Editada: DGM
el 14 de Feb. de 2023
im working on extracting blood vessels on colposcopic image, but after segmentation, the result still has many unexpected objects, i want to keep structures i circled in below image, could you please help me to remove others , i've tried bwareafilt(), bwareaopen, but it didn't work. Thank you so much!

Image Analyst
el 29 de Nov. de 2022
Movida: DGM
el 14 de Feb. de 2023
I'm not sure what about the 30 or so blobs you want to keep is unique about them. Evidently you say it's not their size, or at least not their size alone.
If you want all blobs within a certain distance of the large blobs, perhaps you can use bwareafilt to extract the largest blobs and then dilate the large blobs to get a larger region around them, then erase use imreconstruct to extract those blobs inside or connected to the large blob. Something like
se = strel('disk', 200, 8);
bigMask = imdilate(mask, se);
newMask = imreconstruct(bigMask, mask);
Categorías
Más información sobre Retinal Imaging en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!