cb經過判斷的圖片
cr經過判斷的圖片
只分出膚色的影像
程式碼
clear all
close all
clc
a=imread('nomo.jpg'); % 輸入影像
[c1,c2,c3]=size(a);
b=rgb2ycbcr(a); % 轉換成ycbcr
cb=b(:,:,2);
cr=b(:,:,3);
cb(cb<=125)=255; % cb的判斷式,是人臉為白色
cb(cb~=255)=0;
figure(1);imshow(cb)
cr(cr>=137)=255; % cr的判斷式,是人臉為白色
cr(cr~=255)=0;
figure(2);imshow(cr)
rr=and(cr,cb); % 找出二者都是白的
rt(:,:,1)=double(rr).*double(a(:,:,1));
rt(:,:,2)=double(rr).*double(a(:,:,2));
rt(:,:,3)=double(rr).*double(a(:,:,3));
figure(3);imshow(uint8(rt))
1 則留言:
r95631002 黃聖峰
程式碼
function beework
f=figure('visible','off','position',[360,500,572,504]); % 建window
hstart=uicontrol('Style','pushbutton','String','update','Position',...
[500,400,70,50],'callback',{@updatebutton_callback});% 按鈕
hpopup=uicontrol('Style','popupmenu','String',...
{'plot(x)','pie(x)','hist(y)','ezplot3(f)','polar(theta,r)','area(x,y)'}...
,'Position',[400,400,80,25]); % 選單
htext=uicontrol('Style','text','String','Select Data','Position',[400,430,80,25]); % 說明
hax=axes('Units','pixels','Position',[50,150,300,300]); % 圖window
set([f,hax,hstart,hpopup,htext],'Units','normalized');
plot(rand(5)); % 初始圖
set(f,'Name','beework GUI')
movegui(f,'center')
set(f,'Visible','on');
function updatebutton_callback(source,eventdata)
va=get(hpopup,'value'); % call 選單值
switch va;
case 1
plot(rand(5));
case 2
n=round(10*rand)+10;
pie(2:4:n);
case 3
hist(randn(1000,1));
case 4
ezplot3('t*sin(t)', 'cos(t)', 't', [0,6*pi]);
case 5
theta = linspace(0, 2*pi);
polar(theta, 3+2*rand*cos(4*theta));
case 6
y=[1 1.2 1.5 2*rand;4 4.5 6.6 7*rand;5 6.5 8 15*rand]';
area([1980 1990 2000 2008],y);
grid on;colormap cool;
end
end
end
介面初始圖
plot圖
pie圖
hist圖
ezplot3圖
polar圖
area圖
張貼留言