How to remove background from an image ?

How to remove the artificial background colors and characters from an image and only remain the main object ?
I attached a sample image

回答 (1 件)

Image Analyst
Image Analyst 2015 年 6 月 10 日

0 投票

What are you calling background? And what is "artificial"? What is your definition of "artificial"? You can mask out parts of the image. See my attached demo for that. Can the item for sale in the middle of the picture be any wild colors? Or will they always be grayscale? Please upload 2 or 3 images along with desired output images.

4 件のコメント

Victor Yi
Victor Yi 2015 年 6 月 10 日
the item for sale in the middle of the sample picture can be any color, it is a photo of the item. "background" and "artificial" in my question means they are not the item or a part of the item. Here is another sample image.
<<
>>
Image Analyst
Image Analyst 2015 年 6 月 10 日
What you might try is to convert the RGB image into HSV color space with rgb2hsv(). Then threshold at some high s value because the computer graphics will all be highly saturated, pure colors. Then set those pixels to white or something. Something like
% Convert RGB image into HSV color space.
hsvImage = rgb2hsv(rgbImage);
% Extract individual H, S, and V images.
h = hsvImage(:,:, 1);
s = hsvImage(:,:, 2);
v = hsvImage(:,:, 3);
% Threshold to find vivid colors.
mask = v > 0.7;
% Make image white in mask areas:
h(mask) = 0;
s(mask) = 0;
v(mask) = 1;
% Convert back to RGB
hsvImage = cat(3, h, s, v);
newRGB = hsv2rgb(hsvImage);
Victor Yi
Victor Yi 2015 年 6 月 11 日
Thank you for the sample code ! however it turned out that characters and some of the edges in sample images still remained, is there anything else I should try ?
Image Analyst
Image Analyst 2015 年 6 月 11 日
Try adjusting the saturation threshold. Or use bwareaopen() to get rid of small blobs.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2015 年 6 月 10 日

コメント済み:

2015 年 6 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by