How to eliminate some useless lines in an image?

8 vues (au cours des 30 derniers jours)
Loren99
Loren99 le 5 Juin 2022
Commenté : Image Analyst le 15 Sep 2022
I would like to know if exist a method that cancels the blue lines directly attached to the yellow shapes; for example obtaining only the pink ones (I only traced in pink some of the lines I need, but obviously this has to be extended to the whole image).
How can I do this? Maybe using some proprierties about pixels within the image? I do not know how to procede....

Réponses (1)

Image Analyst
Image Analyst le 5 Juin 2022
Get a yellow mask, and a blue mask, and use imdilate to dilate the yellow blobs by one pixel layer. Then use the yellow as a marker image on the blue image with imreconstruct(). Then use that to erase those from the RGB image.
Something like (untested):
yellowMask = (rgbImage(:,:,1) == 255) & (rgbImage(:,:,2) == 255) & (rgbImage(:,:,3) == 0);
blueMask = (rgbImage(:,:,1) == 0) & (rgbImage(:,:,2) == 0) & (rgbImage(:,:,3) == 255);
yellowMask = imdilate(yellowMask, true(3));
% Extract only blobs where yellow was touching the blue.
mask = imreconstruct(yellowMask, blueMask);
% Mask the image using bsxfun() function to multiply the mask by each channel individually. Works for gray scale as well as RGB Color images.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
  1 commentaire
Image Analyst
Image Analyst le 15 Sep 2022
Not sure what your edit was today, but did you ever try the code I developed for you?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by