canalvideo=videoinput('winvideo',1);
preview(canalvideo);
frame=getsnapshot(canalvideo);
%image(frame);
delete(canalvideo);
prompt = {'Nombre:'};
title = 'ANALISIS CORNEAL';
lines = 1;
def = {'mi imagen'};
answer = inputdlg(prompt,title,lines,def);
assignin('base','imfile',answer{1});
imwrite(frame,strcat(answer{1},'.jpg')); % guarda la imagen , se usa strcat
%porque se van a introducir muchas imagenes, concatena el nombre con la
%extension (primera vez)
% %T=dir('*.jpg');
% a=imread(T.name); otra OPCIONNNNNNNNNN
%a=imread(strcat(answer{1},'.jpg')); % lee
% planeR=a( :, :,1);% reconoce la intensidad del color rojo en la imagen
% planeG=a( :, :,2);% reconoce la intensidad del color verde en la imagen
% planeB=a( :, :,3);% reconoce la intensidad del color azul en la imagen
%
% imwrite(planeR,'plano1.jpg');
% imwrite(planeG,'plano2.jpg');
% EL COLOR AMARILLO SE OBTIENE ENTRE EL PLANO ROJO Y EL PLANO VERDE,QUE
% CORRESPONDEN AL PLANO1 Y AL PLANO2, POR ESTO DEBEMOS HACER EL PLANO 3
% OSEA EL AZUL EN NEGRO
%a(:,:,3)=0;% el plano tres azul lo vuelva negro (hace cambio)}
%imwrite(a,strcat(answer{1},'.jpg')):con esto nos imprime amarillo rgb
b=rgb2hsv(frame);%pase a HSV frame
H=b(:,:,1);%en c guaradmos el plano h
amarillo = 0.12;
precision = 0.1;
c = H(:,:,1)>(amarillo-precision) & H(:,:,1)<(amarillo+precision);
c = uint8(c);
imgAmarillos(:,:,1) = frame(:,:,1).*c;
imgAmarillos(:,:,2) = frame(:,:,2).*c;
imgAmarillos(:,:,3) = frame(:,:,3).*c;
%b(:,:,2)=0;%el plano H lo volvemos cero
%b(:,:,3)=0;
%if (c>=0.2) & (c<=0.3) %la intensidad
%imwrite(c,strcat(answer{1},'1','.jpg'))%guarda plano h en el intervalo de intensidad
%end
imwrite(imgAmarillos,strcat(answer{1},'1','.jpg'))
%imwrite(frame,strcat(answer{1},'.jpg'))%guarda el nuevo cambio
figure; % la pantalla con las imagenes
subplot(2,2,1);% que lleve una imagen a la primera posicion
imshow(frame);% mostrar la primera foto en esa primera posicion
subplot(2,2,2);%que lleve una imagen a la segunda posicion
imshow(imgAmarillos);%mostrar la imagen amarilla en la segunda posicion
%imwrite(planeB,'plano3.jpg');
beep;