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:

采纳的回答

DGM
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;
  2 个评论
Micky Elias
Micky Elias 2021-3-28
Thank you very much sir. This is the explanation I was looking for. yes although I didn't get enough information about the funcition "multimask", now i am able to do the masking.
DGM
DGM 2021-3-28
编辑:DGM 2021-3-28
Multimask is an old simple tool from the MIMT.
There are definitely better tools to use. I just used it as an example because I had it and already had an existing demo. You can generate your mask however you choose.

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
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));

Community Treasure Hunt

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

Start Hunting!

Translated by