how to remove the tiny white pixels around the rectangles

2 vues (au cours des 30 derniers jours)
Pravindkumaran Baskaran
Pravindkumaran Baskaran le 29 Sep 2022
How can i remove the tiny pixels around the rectangles in the image attached. attached images.

Réponse acceptée

Kevin Holly
Kevin Holly le 29 Sep 2022
Img = imread('originalImage.png');
You can also filter based on area of objects
Img = bwareafilt(imbinarize(Img),4,'largest'); % keep the 4 largest objects
  1 commentaire
Pravindkumaran Baskaran
Pravindkumaran Baskaran le 29 Sep 2022
i got till the second image but i'm trying to get those dots around the boxes away

Connectez-vous pour commenter.

Plus de réponses (2)

Matt J
Matt J le 29 Sep 2022
Modifié(e) : Matt J le 29 Sep 2022

Image Analyst
Image Analyst le 29 Sep 2022
Depends on exactly what that means.
  1. Do you want to simply remove small blobs?
  2. Or do you also want to remove a small protrusion that is sticking out of the side of a much larger rectangle.
For case 1 you can use bwareaopen or bwareafilt
For case 2 you might try imopen, though be careful for changes to the shape you don't want, especially near the corners or protruding blobs.

Community Treasure Hunt

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

Start Hunting!

Translated by