how to remove specific area of an image
11 次查看(过去 30 天)
显示 更早的评论
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
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.
采纳的回答
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!