Sunteți pe pagina 1din 2

movegui(hObject, 'center');

-----------------------------------------------------------
IAHI= imaqhwinfo;
IA= (IAHI.InstalledAdaptors);
D= menu ('select Video Input Device',IA);

if isempty(IA)||D==0
msgbox({'you don''t have any Video Input Installed Adaptors!',...
'please try again select Adaptors properly.'})
return
end

IA= char(IA);
IA= IA(D,:);
IA(IA==' ')=[];
x= imaqhwinfo(IA);

try
DeviceID= menu('Select Device ID',x.DeviceIDs);
F= x.Deviceinfo(DeviceID).SupportedFormats;
nF= menu('Select Format',F);
Format =F(nF);
catch
warndlg({'Try Another Device or ID';...
'you Don''t Have Installed This Device (VideoInputDevice)'})
return
end

VidObj=VideoInput(IA,DeviceID,Format);
handles.VidObj=VidObj;
vidRes = get(handles.VidObj,'VideoResolution');
nBands = get(handles,VidObj,'NumberOfBands');

axes(handles.axes1)
hImage= image(zeros(vidRes(2),vidRes(1),nBands));
preview(handles.VidObj,hImage)
set(VidObj,'returnnedcolorspace','rgb');
guidata(hObject,handles);
----------------------------------------------------------------
try
delete(handles,VidObj)
catch
end

axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

cla (handles.axes2,'reset');
cla (handles.axes3,'reset');

----------------------------------------------------------------
try
VidObj=handles.VidObj;
i= getsnapshot(VidObj);

axes(handles.axes2)
imshow(i);
imwrite(i(['image','.jpg']))
catch
end
------------------------------------------------------------------------------------------------------------------------------------------
gambar = handles.data1;
gr = rgb2gray(gambar);
axes(handles.axes3);
imshow(gr);
handles.data2= gr;
guidata(hObject,handles);

------------------------------------------------------------------------------------------------------------------------------------------
gr= handles.data2;
value= get(handles.slider1,'value');
thresh= imcomplement (im2bw(gr,value/255));
axes(handles.axes3);
imshow(thresh);
handles.data3= thresh;
guidata(hObject,handles);
set(handles.edit1,'string',value)

------------------------------------------------------------------------------------------------------------------------------------------
[name_file,name_path]=uigetfile(...
{'*.bmp;*.jpg;*.tif','Files of type (*.bmp,*.jpg*.tif)';
'*.bmp','File Bitmap (*.bmp)';...
'*.jpg','File Jpeg (*.jpg)';
'*.tif','File Tif (*.tif)';
'*.*','All Files (*.*)'},...
'Open Image');

if ~isequal (name_file,0)
handles.data1= imread(fullfile(name_path,name_file));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.data1);
else
return
end

------------------------------------------------------------------------------------------------------------------------------------------

S-ar putea să vă placă și