segmentation using the color thresholder in YCbCr color space
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
DGM
on 28 Mar 2021
Edited: DGM
on 28 Mar 2021
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;
More Answers (1)
Image Analyst
on 28 Mar 2021
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!