how can i select labeled images that are touching the x axis?

4 vues (au cours des 30 derniers jours)
sara
sara le 12 Avr 2015
Commenté : Image Analyst le 30 Mai 2015
i have some labeled objects in an image,is it possible to select only the ones which are connected to the x axis?forexample in this picture the ones i want to choose are the 2 orange ones which are touching the x axis

Réponse acceptée

Image Analyst
Image Analyst le 12 Avr 2015
To get rid of blobs that are touching the edge of the image you can do this:
binaryImage = imclearborder(binaryImage);
That would give the green and blue blobs. Now if you wanted to get just the orange ones and not the green and blue ones, then you have to subtract that from the original image
binaryImage = binaryImage - imclearborder(binaryImage);
or, you can use the xor() function
binaryImage = xor(binaryImage, imclearborder(binaryImage));
This gets extracts the blobs touching any border. If you want only those on the bottom edge, then there is a few more steps. Let me know if that's required.
  5 commentaires
sara
sara le 30 Mai 2015
hi,is this image good to use for removing or selecting blobs which are touching the borders.?this is jpg,when i use im2bw and save the results,it gives me a picture whit white extra borders,so i post the original jpg image,which can be binarized by im2bw,.in some cases i want to detect the one touches an specific border,forexample x-axis,or the pararel axis to it,or y-axis or the pararel axis to it,and in some cases i want to remove the ones whom are touching these axis,and also is it possible to selet the one which touches 2 axis at the same time,mostly in my case there are some labeled images which are touching both x-axis and its pararrel axis(like one of the blobs in the picture,,so im going to select them,and segment them once more,after removing the ones whom only touch x-axis,and in case of margines,im goint to remove some labels whom touch the y-axis or its pararell axis,and x-axis at the same time,so if you can tell me how i can select the one whom touching each border seperately,and also selecting the one touching 2 border at the same time,im so sorry for this much late answer,i was busy segmenting,and just use imclearborder to see are they going to be removed,but in some cases i just want to remove one touches a specific border,and not all borders,thank you so much, i will post this as a seperate question too,thanks
Image Analyst
Image Analyst le 30 Mai 2015
To get rid of objects touching just one border is simple. Simply store the 3 edges of the image that you want to keep. Then zero out those 3 edges and call imclearborder(). Then restore the 3 edges that you zeroed out. Let's say you wanted to delete blobs touching the bottom edge only. Then
% Save 3 edges.
topEdge = binaryImage(1, :);
leftEdge = binaryImage(:, 1);
rightEdge = binaryImage(:, end);
% Zero 3 edges.
binaryImage(1, :) = false;
binaryImage(:, 1) = false;
binaryImage(:, end) = false;
% Get rid of blob(s) touching bottom edge
binaryImage = imclearborder(binaryImage);
% Restore the 3 edges.
binaryImage(1, :) = topEdge;
binaryImage(:, 1) = leftEdge ;
binaryImage(:, end) = rightEdge ;
You could build all that into a function where you pass in the edge(s) you want to remove from.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by