how to remove specific area of an image

11 ビュー (過去 30 日間)
QuestionsAccount
QuestionsAccount 2020 年 11 月 1 日
コメント済み: QuestionsAccount 2020 年 11 月 12 日
hi everyone!
i want to remove only the specific area of my image i.e the floor (but not the whole floor).
for more explanation i attach the image actually i want to remove only the portions of my image that i marked with X sign and the rest of the grass in the middle and the humans remains still there in the image.
Can anyone help in code of doing the above metnion thing. i will be really thankful for that.
Note: background subtraction will not going to solve my problem i need something else more efficent and that fullfil my requirment as well..
  2 件のコメント
Image Analyst
Image Analyst 2020 年 11 月 1 日
Explain what "remove" means to you. Do you want to crop to the grass's bounding box? Do you want to erase the sidewalk (set it to zero)? You can't just "remove" it since images must remain rectangular not trapezoidal.
QuestionsAccount
QuestionsAccount 2020 年 11 月 3 日
編集済み: QuestionsAccount 2020 年 11 月 3 日
by remove i meant to erase the sidewalk (set it to zero) and the rest of the humans and the grass in the center remains same.(only the pixels values in the side walk that i marked with X sign will be set to zero and the rest of the pixels values remains same).
one option that comes in my mide is to use color feature and set the color of side walk to zero while the rest of the colors remains same. but how can i do this in matlab please help me in code this because i didn't figure it out.
i also used K-means clustering for doing above mention work but that also didn't give me the desired results.
your help in codding is highly appreciated.thanx.
for sake of understanding what i desired, i attached image by manually draw the black color in it. output result that i want is attached as (test_img_2).

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

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 11 月 4 日
Hi, you can use the interactive Color Thresholder app to achieve what you want. After performing segmentation, this app also generates the equivalent MATLAB code. Below is an example of the code generated by the Color Thresholder app.
I = imread('original.jpg');
% Define thresholds for channel 1 based on histogram settings
channel1Min = 203.000;
channel1Max = 245.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 202.000;
channel2Max = 234.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 197.000;
channel3Max = 227.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = I;
% Set background pixels where BW is true to zero.
maskedRGBImage(repmat(BW,[1 1 3])) = 0;
figure
montage({I, BW, maskedRGBImage}, 'Size', [1 3])
title('RGB image | Segmentation mask | Segmented image')
  1 件のコメント
QuestionsAccount
QuestionsAccount 2020 年 11 月 12 日
@Subhadeep Koley thank you very much for your help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by