前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >用于摄像头捕获的图像(白色背景)增强和分割。

用于摄像头捕获的图像(白色背景)增强和分割。

作者头像
裴来凡
发布2022-05-28 15:18:45
8400
发布2022-05-28 15:18:45
举报
文章被收录于专栏:图像处理与模式识别研究所
代码语言:javascript
复制
%camList = webcamlist;
% cam = webcam(1);
% img= snapshot(cam);
% clear cam;
% img=imread('5.jpg');
%to make user choose the images from directory
[fname,fpath]=uigetfile('.png','choose image');
img_fullpath=[fpath,fname];
img=imread(img_fullpath);
YCBCR = rgb2ycbcr(img);
ii=imresize(YCBCR, [128 128]);
s = strel('ball',2,2);
f = imclose(ii,s); 
i1=rgb2gray(f);
th=graythresh(i1);
i2=im2bw(i1,th);
i3=imcomplement(i2);
i3=imfill(i3,'holes');
i4=edge(i3,'prewitt');
%i5=imerode(i1,s);
%original image
subplot(1,3,1);
imshow(img)
%gray image
subplot(1,3,2);
imshow(i3)
% edge image
subplot(1,3,3);
imshow(i4)
%recognition part-----------------------------------
s1=strel('disk',6);
palm=imopen(i3,s1);
fingers=i3-palm;
figure,
imshow(fingers)
s=strel('disk',2);
i6=imerode(fingers,s);
figure,
imshow(i6);
i7 = bwconncomp(i6,4);
number = i7.NumObjects;
title(number);

project.m

代码语言:javascript
复制
%camList = webcamlist;
% cam = webcam(1);
% img= snapshot(cam);
% clear cam;
% img=imread('5.jpg');
%to make user choose the images from directory
[fname,fpath]=uigetfile('.png','choose image');
img_fullpath=[fpath,fname];
img=imread(img_fullpath);
YCBCR = rgb2ycbcr(img);
ii=imresize(YCBCR, [128 128]);
s = strel('ball',2,2);
f = imclose(ii,s); 
i1=rgb2gray(f);
th=graythresh(i1);
i2=im2bw(i1,th);
i3=imcomplement(i2);
i3=imfill(i3,'holes');
i4=edge(i3,'prewitt');
%i5=imerode(i1,s);
%original image
subplot(1,3,1);
imshow(img)
%gray image
subplot(1,3,2);
imshow(i3)
% edge image
subplot(1,3,3);
imshow(i4)
%recognition part-----------------------------------
s1=strel('disk',6);
palm=imopen(i3,s1);
fingers=i3-palm;
figure,
imshow(fingers)
s=strel('disk',2);
i6=imerode(fingers,s);
figure,
imshow(i6);
i7 = bwconncomp(i6,4);
number = i7.NumObjects;
title(number);

project.m

代码语言:javascript
复制
%camList = webcamlist;
% cam = webcam(1);
% img= snapshot(cam);
% clear cam;
% img=imread('5.jpg');
%to make user choose the images from directory
[fname,fpath]=uigetfile('.png','choose image');
img_fullpath=[fpath,fname];
img=imread(img_fullpath);
YCBCR = rgb2ycbcr(img);
ii=imresize(YCBCR, [128 128]);
s = strel('ball',2,2);
f = imclose(ii,s); 
i1=rgb2gray(f);
th=graythresh(i1);
i2=im2bw(i1,th);
i3=imcomplement(i2);
i3=imfill(i3,'holes');
i4=edge(i3,'prewitt');
%i5=imerode(i1,s);
%original image
subplot(1,3,1);
imshow(img)
%gray image
subplot(1,3,2);
imshow(i3)
% edge image
subplot(1,3,3);
imshow(i4)
%recognition part-----------------------------------
s1=strel('disk',6);
palm=imopen(i3,s1);
fingers=i3-palm;
figure,
imshow(fingers)
s=strel('disk',2);
i6=imerode(fingers,s);
figure,
imshow(i6);
i7 = bwconncomp(i6,4);
number = i7.NumObjects;
title(number);



本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-05-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 图像处理与模式识别研究所 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档