cant seem to make the background fully black

조회 수: 1 (최근 30일)
Pravindkumaran Baskaran
Pravindkumaran Baskaran 2022년 9월 30일
편집: Matt J 2022년 10월 1일
I have uploaded two images, one is the original image and the other one is a processed image. i am wondering how can i make the background fully black because i cant seem to make the bottom right fully black in the processed image. i have processed the image by thresholding, binarising and inverting it.

채택된 답변

Matt J
Matt J 2022년 9월 30일
편집: Matt J 2022년 9월 30일
A=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141370/original.png');
B=imquantize(A,multithresh(A,3));
C=1;
for i=1:4
C=C & ~bwareafilt(B==i,[80000,inf]);
end
imshow(C,[])
  댓글 수: 2
Pravindkumaran Baskaran
Pravindkumaran Baskaran 2022년 9월 30일
thank you very much !
Image Analyst
Image Analyst 2022년 10월 1일
If you want the shapes to have their original gray level and class (like uint8 or uint16), instead of being a binary (logical) image, you can use that mask to set the background to zero and leave the original gray levels untouched:
% Blacken background:
A(~C) = 0;

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

추가 답변 (2개)

Image Analyst
Image Analyst 2022년 9월 30일
Looks a lot like homework. Is it?
What I'd try first is to create a background and then subtract it from the image. You can construct a background by getting the values along the edges, or the corners and then using biliear interpolation, like with interp1 to build the background. Should be easy - try it.

Matt J
Matt J 2022년 9월 30일
편집: Matt J 2022년 10월 1일
A=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141370/original.png');
B=imclose(edge(A),strel('disk',5));
C=imfill(B,'holes');
imshow(C,[])

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by