How to remove image background in Matlab

How would I remove the gray background in the grayscale image so i could put a white backgound instead? Please help.. I'm a newbie in Matlab. i'm out of touch on these.. it just an assignment sir.. can you lend me a hand .. please. :((
(original image)
(desired output)

 채택된 답변

DGM
DGM 2022년 11월 4일
편집: DGM 2022년 11월 4일
Here is one simplistic example.
% an image
A = imread('coins.png');
% basic thresholding to select objects
mk = A>100;
% fill any holes in objects
mk = imfill(mk,'holes');
% add colored overlay on background region
bgcolor = [0.7 0.3 1]; % white or any color
outpict = imoverlay(A,~mk,bgcolor);
imshow(outpict)
Bear in mind that if the goal is to change colors in an image, simple binary masking isn't always a good solution for all needs. It will always leave ragged edges on the output. If this is technical image processing where visual appearances aren't important, then logical is probably appropriate.
Similarly, color adjustment by constant replacement destroys all content in the altered regions. Sometimes that's intended, sometimes not.

댓글 수: 1

Kalixta
Kalixta 2022년 11월 4일
ow. okay sir. thank you for the help. i will keep these in mind. ^^

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2022년 11월 4일

댓글:

2022년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by