I want to make a background black and foreground is same as original.

2 ビュー (過去 30 日間)
Sandeep parajuli
Sandeep parajuli 2020 年 6 月 29 日
回答済み: Puru Kathuria 2020 年 7 月 22 日
O=imread('wed.jpg');
figure,imshow(O);
whos O
C=rgb2gray(O);
figure,imshow(C);
b=C > 128;
whos b
[m n]=size(b)
for i=1:m
for j=1:n
if (b(i,j)==1)
bIn3Dims(i,j,:)= O(i,j,:)
end
end
end
figure,imshow(b)

回答 (1 件)

Puru Kathuria
Puru Kathuria 2020 年 7 月 22 日
Hi,
You can try activecontour and lazysnapping. Both of them are for segmenting image into background and foreground using contours and graph-based segmenting respectively.
Also have a look at this Image Segmentation Tutorial.
References/Citations:
Image Analyst (2020). Image Segmentation Tutorial, MATLAB Central File Exchange. Retrieved July 22, 2020.

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by