%%To clear the matlab window and close figure window
workspace;
%%
%%Get an image and convert into rgb& hsv
%vid = videoinput('winvideo', 1, 'YUY2_640x480');
colorimage=getsnapshot(vid);
%src = getselectedsource(vid);
%vid.FramesPerTrigger = 1;
% colorimage=imread('1.jpg');
% colorimage=start(vid);
dblimage=im2double(colorimage);
redimage=colorimage(:,:,1);
blueimage=colorimage(:,:,2);
greenimage=colorimage(:,:,3);
hsvImage = rgb2hsv(colorimage);
hImage = hsvImage(:,:,1);
sImage = hsvImage(:,:,2);
vImage = hsvImage(:,:,3);
%%
%Thresholding the image and creating mask
hueThresholdLow = 0;
hueThresholdHigh = graythresh(hImage);
saturationThresholdLow = graythresh(sImage);
saturationThresholdHigh = 1.0;
valueThresholdLow = graythresh(vImage);
valueThresholdHigh = 1.0;
hueMask = (hImage >= hueThresholdLow) & (hImage <= hueThresholdHigh);
saturationMask = (sImage >= saturationThresholdLow) & (sImage <= saturationThresholdHigh);
valueMask = (vImage >= valueThresholdLow) & (vImage <= valueThresholdHigh);
%%
%creating yellow mask
yellowObjectsMask = uint8(hueMask & valueMask);
%figure,imshow(yellowObjectsMask, []);
yellowObjectsMask = uint8(bwareaopen(yellowObjectsMask, 100));
%figure,imshow(yellowObjectsMask, []);
%%masking noise
mask = strel('disk',8);
%figure,imshow(yellowObjectsMask, []);
% title('Masked Image')
yellowObjectsMask1 = imerode(yellowObjectsMask,mask);
% yellowObjectsMask1 = imerode(yellowObjectsMask1,mask);
% yellowObjectsMask1 = imerode(yellowObjectsMask1,mask);
% yellowObjectsMask1 = imerode(yellowObjectsMask1,mask);
figure,imshow(yellowObjectsMask1, []);
title('Disk Masked Image')
% structuringElement = strel('disk', 2);
% yellowObjectsMask = imclose(yellowObjectsMask, structuringElement);
% % Fill in any holes in the regions, since they are most likely red also.
% yellowObjectsMask = uint8(imfill(yellowObjectsMask, 'holes'));
% %figure,imshow(yellowObjectsMask, []);
%
% % We need to convert the type of yellowObjectsMask to the same data type as hImage.
% yellowObjectsMask = cast(yellowObjectsMask, class(colorimage));
% maskedImageR = yellowObjectsMask .* colorimage(:,:,1);
% maskedImageG = yellowObjectsMask .* colorimage(:,:,2);
% maskedImageB = yellowObjectsMask .* colorimage(:,:,3);
% maskedRGBImage = cat(3, maskedImageR, maskedImageG, maskedImageB);
% %figure,imshow(maskedRGBImage);
%figure,imshow(colorimage);
fire-identification.rar_The Fire_fire_matlab fire
版权申诉
197 浏览量
2022-09-20
19:50:33
上传
评论
收藏 2KB RAR 举报
JaniceLu
- 粉丝: 78
- 资源: 1万+
最新资源
- 基于python弹幕情感分析的直播高光时刻判断模型设计与系统实现
- (精品)第4章数控铣床和加工中心工艺与编程.ppt
- (精品)第6章卫星移动通信系统.ppt
- TI杯大奖赛本科组+研究生组论文+源代码+PCB基于TMS320F28335的超声波流量计
- TI杯大奖赛本科组+研究生组论文+源代码+PCB基于TMS320F2812的图像识别智能跟踪小车
- PuTTY Connection Manager ( puttyCM )
- TI杯大奖赛本科组+研究生组论文+源代码+PCB基于TMS320F2812的节能环保型矩阵式变频器的开发
- C语言:消息通信实例代码,主函数实现消息发送与消息接收功能
- (HTML+CSS+jQuery)学生仿手机端静态外卖项目
- 车载软件的OTA方案需求确认内容
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈