how to remove specific area of an image

조회 수: 8 (최근 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 CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by