how to remove the tiny white pixels around the rectangles

조회 수: 1 (최근 30일)
Pravindkumaran Baskaran
Pravindkumaran Baskaran 2022년 9월 29일
답변: Image Analyst 2022년 9월 29일
How can i remove the tiny pixels around the rectangles in the image attached. attached images.

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt J
Matt J 2022년 9월 29일
편집: Matt J 2022년 9월 29일
imopen(yourImage,ones(3))

Image Analyst
Image Analyst 2022년 9월 29일
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