segmentation using the color thresholder in YCbCr color space
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am working on the fire detection using the combined tecniques of color and motion detection. what I want to do is first apply the color thresholding step and use the output from the first step as the input for the motion detection. Can anyone help me on how to remove the background without changing it into the binary image.
my main aim is turning the non-fire colored region into black without changing foreground so that I can reduce errors during the motion detection phase as the following image:
0 个评论
采纳的回答
DGM
2021-3-28
编辑:DGM
2021-3-28
If I get your question correctly, you already have a means of generating a mask; you're asking how to apply the mask.
Consider this example:
% i have a mxnx3 rgb image that i want to reduce
inpict=imread('sources/colorballs.jpg');
% i have a mxnx1 mask generated by some means
mask=multimask(inpict,{'ge','le'},[0.85 0.33 0.05; 1 1 0.63]*255,'and');
% despite the mismatched number of channels,
% i can use the mask to remove content from the image like so:
outpict=im2double(inpict);
outpict=bsxfun(@times,outpict,mask);
If you're running R2016b or newer, you don't even need to do that. Implicit expansion will take care of it:
outpict2=im2double(inpict);
outpict2=outpict2.*mask;
更多回答(1 个)
Image Analyst
2021-3-28
Here is a way to apply a mask to an image. Works for gray scale or color, and multiple class types.
% Mask the image using bsxfun() function to multiply the mask by each channel individually. Works for gray scale as well as RGB Color images.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!